Ilogic Rule to change visibility of components using part of file name

Ilogic Rule to change visibility of components using part of file name

Anonymous
Not applicable
627 Views
1 Reply
Message 1 of 2

Ilogic Rule to change visibility of components using part of file name

Anonymous
Not applicable

Is there a rule to change the visibility of compontents based on there name?

 

I am only new to using rules and so my knowledge is lacking a little. I have an assembly in which i have multiple sub assemblies that all contain similar parts, i am needing to turn off all of the parts in the main assembly that share a similar name.

 

Eg. The parts i need are all cover sheets of plywood and all share the name Gx-PLY-x, so i am chasing a rule that i can run that will find all components that share the -PLY- name and have them change visibility state

0 Likes
628 Views
1 Reply
Reply (1)
Message 2 of 2

WCrihfield
Mentor
Mentor

Do only the parts you want contain "-PLY-", and no other parts names contain that text?

Do you want to search the ComponentOccurrence names (as seen in the Model browser of your main assembly), or do you want to search by their file names?  I could also search by their Part Number (in iProperties), if needed.

The following code loops through all ComponentOccurrences within the main assembly, and checks to see if their names contain "-PLY-".  If it does, it turns their visibility off.

Try this code:

 

If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then
	MsgBox("This rule '" & iLogicVb.RuleName & "' only works for Assembly Documents.",vbOK, "WRONG DOCUMENT TYPE")
	Return
End If

Dim oADoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim oADef As AssemblyComponentDefinition = oADoc.ComponentDefinition
For Each oOcc As ComponentOccurrence In oADef.Occurrences
	If oOcc.Name.Contains("-PLY-") Then
		oOcc.Visible = False
	End If
Next

 

 

I hope this helps.
If this solves your problem, or answers your questions, please click 'Accept As Solution".
Or, if this helps you reach your goal, please click 'LIKES" 👍.

 

Also, if you're interested, here are a few of the 'Ideas' I'd like to get implemented.
If you agree with any of them, please vote for them.

  • Add more capabilities to the 'Customize' dialog box (exe. Add Tab & Add Panel) Click Here
  • Constrain & Dimension Images In Assembly Sketches & Drawing Sketches (TitleBlocks & SketchedSymbols) Click Here
  • Save Section View Status In DesignViewRepresentation (So It Can Be Used In The Drawing) Click Here
  • Add SolidBodies Folder In iLogic Rule Editor Model Tab Click Here
  • Convert All Views To Raster Before Autosave Stores To 'OldVersions' Folder Click Here
  • SetDesignViewRepresentation - Fix limitations for DrawingView of a Part Click Here
  • Create DocumentSubTypeEnum Click Here
  • Add kRevisionTag or kDrawingRevisionTag to ObjectTypeEnum Click Here

Inventor 2020 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes