×
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

Traverse Assembly - Add Custom Property

Traverse Assembly - Add Custom Property

Traverse Assembly - Add Custom Property

(OP)
I am trying to write what I thought would be an easy API script. All I want it to do is to traverse all parts in an assembly and add some custom properties to them. I have managed to get it done with one method, but that way flashes each part across teh screen. I would prefer if it did not do that. I have written this, and it traverses the assembly and can debug print, each child. But I cannot get it to add the property.


What am I missing. Thank you in advance for you help and time.
______________________________________________

Sub Main()

Dim swApp           As SldWorks.SldWorks
Dim swModel         As SldWorks.ModelDoc2
Dim refModel        As SldWorks.ModelDoc2
Dim CustPM          As SldWorks.CustomPropertyManager

Dim nErrors         As Long
Dim nwarnings       As Long
Dim ChildName       As String
Dim AddProp         As String
Dim vChild          As Variant
Dim vParent         As Variant

Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc

vParent = swModel.GetPathName

Debug.Print vParent

vChild = swApp.GetDocumentDependencies2(vParent, True, False, False)

For i = 1 To (UBound(vChild)) Step 2
    
Debug.Print vChild(i)

Set refModel = swApp.OpenDoc6(vChild(i), swDocPART, swOpenDocOptions_Silent, "", nErrors, nwarnings)

Set CustPM = refModel.Extension.CustomPropertyManager("")

AddProp = CustPM.Add2("My test", swCustomInfoText, "Blah")

Next i

End Sub

RE: Traverse Assembly - Add Custom Property

(OP)
Nevermind...I went and had lunch and when I came back. the code seems to work just fine.

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