I-Logic with Derived Parts

I-Logic with Derived Parts

cwilliamson232RQ
Enthusiast Enthusiast
2,087 Views
17 Replies
Message 1 of 18

I-Logic with Derived Parts

cwilliamson232RQ
Enthusiast
Enthusiast

Is there a way to Turn on and off my Derived Part thru I-logic? 

 

0 Likes
2,088 Views
17 Replies
Replies (17)
Message 2 of 18

johnsonshiue
Community Manager
Community Manager

Hi! I am sorry that I don't understand the request. You want to turn on/off a derived part in an assembly? Or, you want to turn on/off derived feature within the derived part? Or, you want to drive derive or not from the source part?

Many thanks!



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
0 Likes
Message 3 of 18

cwilliamson232RQ
Enthusiast
Enthusiast

So I have a part and inside that Part I have a Derived Part called "BOLT". I created a Parameter called "HARDWARE" and it is a multi-value text with the values "ON" and "OFF". I can I make the I-Logic be able to Turn the Derived Part 'BOLT" to be ON and OFF. 

0 Likes
Message 4 of 18

johnsonshiue
Community Manager
Community Manager

Hi! I think it is doable. You want to suppress, right? Are you trying to make Text parameter in an iPart?

Many thanks!



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
0 Likes
Message 5 of 18

cwilliamson232RQ
Enthusiast
Enthusiast

Yes Suppress and Yes an IPart.

 

0 Likes
Message 6 of 18

A.Acheson
Mentor
Mentor

Can you attach an a simple part showing your workflow. There are a few ways to derive so we would need to target the way you are manually deriving at the moment in order to replicate. Controlling an iPart through the factory can be tricky due to the members needing to update. Derive should be easier. Here is some reading on derived parameters. 
https://help.autodesk.com/view/INVNTOR/2021/ENU/?caas=caas/discussion/t5/Inventor-Customization/iLog...

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 7 of 18

cwilliamson232RQ
Enthusiast
Enthusiast

Here is a simple I-part with a Derived Part in it that I broke the Link. 

0 Likes
Message 8 of 18

cwilliamson232RQ
Enthusiast
Enthusiast

Here is a better Example

 

0 Likes
Message 9 of 18

cwilliamson232RQ
Enthusiast
Enthusiast

Can you try the derived part with my test part i sent? 

 

0 Likes
Message 10 of 18

cwilliamson232RQ
Enthusiast
Enthusiast

How?

0 Likes
Message 11 of 18

A.Acheson
Mentor
Mentor

@cwilliamson232RQ 

I will try this if I get a chance, hopefully other users have experience with this also. Is it a inv 2020 or earlier file? Otherwise I am out unfortunately. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 12 of 18

cwilliamson232RQ
Enthusiast
Enthusiast

It is in Inventor 2020

0 Likes
Message 13 of 18

A.Acheson
Mentor
Mentor

I was able to turn off the derived part in this derived part you have attached.  Below is how this is achieved and I have included this in the attached part. Depending on how you are going to use this, it will need to be adapted, have you a larger end goal? 

 

'https://forums.autodesk.com/t5/inventor-customization/ilogic-rule-to-include-exclude-derived-parameter-in-all-parts/td-p/8691196

If ThisApplication.ActiveDocument.DocumentType <> kPartDocumentObject Then
	MessageBox.Show("Make a Part Document the active document,Exiting", "iLogic") 
Else
	
	Dim oDerSolidBodyList As New ArrayList
	
	Dim oDerPart As PartDocument
	oDerPart = ThisApplication.ActiveDocument

	'Look for Derived part components
	If oDerPart.ComponentDefinition.ReferenceComponents.DerivedPartComponents.Count < 1 Then
		MessageBox.Show("No Derived Part Components in this part", "iLogic")   

	Else
		' Set a reference to the part component definition
		Dim oDerPartCompDef As PartComponentDefinition
		oDerPartCompDef = oDerPart.ComponentDefinition
		
		'Get a reference to derived part components in this part
		Dim oDerPartComps As DerivedPartComponents
		oDerPartComps = oDerPartCompDef.ReferenceComponents.DerivedPartComponents
		
		'Get a reference to derived part component
		Dim oDerPartComp As DerivedPartComponent
		oDerPartComp = oDerPartComps(1)'1st component
		
		' Derived part component by name
		'MessageBox.Show(oDerPartComp.Name, "iLogic")
		
		'ReferenceFeature objects 'Found in API Help searching solidbody
		Dim oDerSolidBodies As ReferenceFeaturesEnumerator
		oDerSolidBodies = oDerPartComp.SolidBodies
		
		Dim oDerSolidBody As ReferenceFeature
		
		For Each oDerSolidBody In oDerSolidBodies
			'Add each solid body to array list
			oDerSolidBodyList.Add(oDerSolidBody.Name)
			'MessageBox.Show(oDerSolidBody.Name, "iLogic")
			
			If HARDWARE = "OFF" Then
				oDerSolidBody.Suppressed = True
			ElseIf HARDWARE = "ON" Then
				oDerSolidBody.Suppressed = False
			End If	
			
		Next
		'oDerSolidBodyName = InputListBox("Select one", oDerSolidBodyList, oDerSolidBodyName, Title := "Title", ListName := "Solid Body List")
	End If
End If

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 14 of 18

cwilliamson232RQ
Enthusiast
Enthusiast

So seems this Suppresses ALL of my Derived parts. Is there a way to specify specific Derived Parts Only? 

0 Likes
Message 15 of 18

A.Acheson
Mentor
Mentor

This snippet targets the first derived component in your part, in your case the derived assembly by number but you could also type an occurence name.  

 

'Get a reference to derived part component
		Dim oDerPartComp As DerivedPartComponent
		oDerPartComp = oDerPartComps(1)'1st component
		
		' Derived part component by name
		'MessageBox.Show(oDerPartComp.Name, "iLogic")

 

In your case you have multiple parts in a derived assembly so you would need to target the solid body by name or number with this snippet.

oDerSolidBody.Name


So is it parts (solid body) in the derived assembly you need to target or just the main derived part? You could put the list of derived components and solid bodies in an array list box and deselect one by one what you don’t want/add what you do want.  This filtering will really depend how frequent you will use this rule and what you may need to filter. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 16 of 18

cwilliamson232RQ
Enthusiast
Enthusiast

The array list might work best. So say I have 15 Derived parts but only 5 of those are going to be considered "HARDWARE" so I can turn those 5 on and off. 

 

So in that I-logic code you posted. Which lines are supposed to be COMMENTED out? 

cwilliamson232RQ_0-1620226719242.png

So replace this name with ASSY_Bolt_Carraige_0.375x1.ipt  

0 Likes
Message 17 of 18

cwilliamson232RQ
Enthusiast
Enthusiast

Here is a updated part with a few more derived parts in it. 

 

0 Likes
Message 18 of 18

A.Acheson
Mentor
Mentor

If the derived assembly components are not going to change name  run a filter like the below based on the occurrence name. I haven't tested this so hopefully there isn't any issues. There maybe other easiers ways. 

 

'Get a reference to derived part component
Dim oDerPartComp As DerivedPartComponent
Dim ExcludeList As New ArrayList
'add the exclusion occurance names here
ExcludeList.add ("ASSY_Bolt_Carraige_0.375x1.ipt")
'ExcludeList.add ("...............")
Dim oExcludePart As String
For Each oDerPartComp in oDerPartComps
For Each oExcludePart in Excludelist
'Remove this derived part from the search
If Not oDerPartComp.Name Then
...... Turn off solid bodies here
End IF
Next
Next

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes