×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Accessing Properties

Accessing Properties

Accessing Properties

(OP)
Does anyone know how to access custom properties of a part through a drawing?

I am writing some code which runs on a drawing but I also need to access some of the properties of the part/assembly that it references.

Any ideas?

Thanks  

RE: Accessing Properties

What will make this complicated for you is that there is not necessarily a unique model associated with a drawing.  Drawings have sheets.  Sheets have views, and views are associated with models.  Assuming that drawing is a SldWorks.DrawingDoc for the current drawing and the first view of the active sheet references the desired model then the following code will set model to the SldWorks.ModelDoc2 object for the referenced model and configName to the referenced config of the model.

This code is pieced together from an old project, so it may not work without some fixing, but it should get you headed in the right direction though.

Eric

CODE

Dim currentView As SldWorks.view
Dim model As SldWorks.ModelDoc2
Dim configName as String

Set currentView = drawing.GetFirstView()
If Not currentView Is Nothing Then
    Set currentView = currentView.GetNextView
End If

If Not currentView Is Nothing Then
    Set model = currentView.ReferencedDocument
    configName = currentView.ReferencedConfiguration
End If

RE: Accessing Properties

(OP)
Thanks for a point in the right direction Eric :)

RE: Accessing Properties

A drawing connects to parts and assemblies through the views.  You need to get the view, then get the associated part or assembly.  Likewise, BOMs are associated with views, not entire drawings.  To get a BOM's model, you need to find its view and then access the model.

If you add a view of a single part and the BOM of interest is attached to a view of a parent assembly, there probably won't be an association of the BOM item number.  If the view is of the same assembly with all other parts invisible, the association may hold.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources