Message 1 of 14
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
All,
I have a problem, i am targeting components (parts) based off what the mate name is and then running ilogic code to change the parents visibility on or off.
The Code is run inside a Assembly as an "External Rule"
Here is my Current Code that works, but is not future proof since it still targets a hard coded string name like so:
somenameofpart:1
somenameofpart:2
somenameofpart:3
notice :1, :2, :3
here is the family tree of the mates:
Dim openDoc As Document openDoc = ThisDoc.Document Dim docFile As Document If openDoc.DocumentType = 12291 Then For Each docFile In openDoc.AllReferencedDocuments If docFile.DocumentType = 12290 Then Dim FNamePos As Long FNamePos = InStrRev(docFile.FullFileName, "\", -1) Dim docFName As String docFName = Right(docFile.FullFileName, Len(docFile.FullFileName) - FNamePos) 'ShortName = Left(docFName, Len(docFName)) 'MessageBox.Show(ShortName) ShortName = Left(docFName, Len(docFName) - 4) 'MessageBox.Show(ShortName & Right(docFName, Len(docFName) + 2)) Try If Constraint.IsActiveInComponent(ShortName & ":1", "VERTICAL") = True Then 'do nothing Else 'turns off component that has Vertical Mate active Component.Visible(ShortName & "1") = True Constraint.IsActive("VERTICAL")=True End If If Constraint.IsActiveInComponent(ShortName & ":2", "LEFT") = True Then Component.Visible(ShortName & "2") = False Constraint.IsActive("LEFT")=False Else 'dont try to turn off if you dont need to End If If Constraint.IsActiveInComponent(ShortName & ":3", "RIGHT") = True Then Component.Visible(ShortName & "3") = False Constraint.IsActive("RIGHT")=False Else 'dont try to turn off if you dont need to End If Catch End Try ThisDoc.Document.Rebuild() End If Next Else MessageBox.Show("You must have a valid Assembly document open before using this code!", "File Type Mismatch!",MessageBoxButtons.OK,MessageBoxIcon.Exclamation) End If
how can i get it to work with targeting a dynamic name a unkown component name that has a mate called:
VERTICAL, LEFT, RIGHT?
i dont want to rely on :1, :2, :3 as a hardcoded statement.
Thanks

..........................................................................................................................
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
..........................................................................................................................
See My LinkedIn Profile
Solved! Go to Solution.