Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

iLogic To Suppress Link To A Derived Assembly

kwalker1
Enthusiast

iLogic To Suppress Link To A Derived Assembly

kwalker1
Enthusiast
Enthusiast

I have a large sub-assembly which has been shrinkwrapped to it's own part file.

I am then trying to suppress the link to its base component via iLogic code placed in the shrinkwrap part file.

 

All searches on this forum relate to a Derived Part inside an assembly file, whereas I have a Derived Assembly inside a part file.

image.png

 

I have picked up some code from the following post:

Supress Link with base component ilogic

and then modified it for a derived assembly instead as follows but nothing seems to happen once the code is successfully run.

 

Sub Main()

Dim oShrinkwrap As PartDocument
oShrinkwrap = ThisApplication.ActiveDocument

Dim occ As ComponentOccurrence
Dim derivedAssembly As DerivedAssemblyComponent

For Each occ In oShrinkwrap.ComponentDefinition.Occurrences
    For Each derivedAssembly In occ.Definition.ReferenceComponents.DerivedAssemblyComponents
		
		derivedAssembly.SuppressLinkToFile = True
        
        iLogicVb.UpdateWhenDone = True
        
	Next
	
Next

End Sub

 

If anyone can assist me with this then it would be much appreciated.

 

Cheers.

0 Likes
Reply
Accepted solutions (1)
1,756 Views
7 Replies
Replies (7)

chandra.shekar.g
Autodesk Support
Autodesk Support

@kwalker1,

 

Can you please provide Part Document with Derived assembly to test the code? Please make sure that files are non confidential.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes

kwalker1
Enthusiast
Enthusiast

Hi Chandra,

Thanks for the message.

 

Please find attached a simplified example model with the iLogic code.

The code is located within the STRUCTURE ASSEMBLY (SHRINKWRAPPED).ipt file.

It is triggered when the shrinkwrap's Save Date & Time Stamp custom iproperty does not match the STRUCTURE ASSEMBLY.iam file's Save Date & Time Stamp custom iproperty.

 

Hence to auto run the code, first open and save the STRUCTURE ASSEMBLY.iam then open the shrinkwrap file.

 

I have been slowly getting a handle on writing iLogic code but occasionally get stuck on some parts so any help is very much appreciated.

 

Regards,

Kurt.

0 Likes

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

@kwalker1,

 

Actually, attached part contains ShrinkWrap Component.

 

Unfortunately, SuppressLinkTOFile property is not supported for ShrinkWrap component in Inventor 2018. But it is supported in Inventor 2019. Try below iLogic code to ShrinkWrap Component.

 

Sub Main()

	Dim oShrinkwrap As PartDocument
	oShrinkwrap = ThisApplication.ActiveDocument

	Dim oDef As PartComponentDefinition 
	oDef = oShrinkwrap.ComponentDefinition 
	 
	Dim oShrinkComp As ShrinkwrapComponent
	For Each oShrinkComp In oDef.ReferenceComponents.ShrinkwrapComponents 
		
		oShrinkComp.SuppressLinkTOFile = True 
		
		iLogicVb.UpdateWhenDone = True

	Next

 

'UPDATE SHRINKWRAP SAVE DATE & TIME STAMP
'iProperties.Value("Custom", "SHRINKWRAP SAVE DATE & TIME STAMP") = iProperties.Value("STRUCTURE ASSEMBLY.iam", "Custom", "STRUCTURE SAVE DATE & TIME STAMP")

'MessageBox.Show("Executing iLogic Code", "Executing iLogic Rule Confirmation")

End Sub

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes

kwalker1
Enthusiast
Enthusiast

Thanks very much Chandra for the information and adjusted code.

I have now installed Inventor 2019 and it works great.

 

But I'm encountering one other problem.

 

I'm trying to trigger the code to only run when the shrinkwrap file's Date & Time Stamp iproperty does not match the base component's Date & Time Stamp iproperty.

If triggered, the code will:

1. Unsuppress link with base component

2. Update the shrinkwrap

3. Re-suppresses link with base component

4. Then updates the shrinkwrap's Date & Time Stamp iproperty to match the base component's Date & Time Stamp iproperty.

 

The problem I'm having is that I can't seem to read the base component's iproperty because it is suppressed.

image.png

 

 

I have tried the following 2 pieces of code but both won't work for me.

Is there a way to call up an iproperty value of another file which has not be placed / derived / made active within the file that contains the code?

 

'UPDATE SHRINKWRAP SAVE Date & TIME STAMP

iProperties.Value("Custom", "SHRINKWRAP SAVE DATE & TIME STAMP") = iProperties.Value("STRUCTURE ASSEMBLY.iam", "Custom", "STRUCTURE SAVE DATE & TIME STAMP")
'UPDATE SHRINKWRAP SAVE DATE & TIME STAMP (CODE TEST 2)
	
Dim baseComponentFilePath As String
	
baseComponentFilePath = ThisDoc.Path + "\STRUCTURE ASSEMBLY.iam"
	
iProperties.Value("Custom", "SHRINKWRAP SAVE DATE & TIME STAMP") = iProperties.Value(baseComponentFilePath, "Custom", "STRUCTURE SAVE DATE & TIME STAMP")

I have attached an updated model with the code I'm using.

Many thanks for the help.

0 Likes

chandra.shekar.g
Autodesk Support
Autodesk Support

@kwalker1,

 

Try below iLogic rule to update custom iProperty from ShrinkWrap component to part document.

 

Sub Main()
	
	Dim oShrinkwrap As PartDocument
	oShrinkwrap = ThisApplication.ActiveDocument
	
	Dim oDef As PartComponentDefinition
	oDef = oShrinkwrap.ComponentDefinition
	
	Dim oShrinkComp As ShrinkwrapComponent
	For Each oShrinkComp In oDef.ReferenceComponents.ShrinkwrapComponents
		 
		oShrinkComp.SuppressLinkToFile = False 	
		
		iLogicVb.UpdateWhenDone = True
		
	Next
	
	For Each oShrinkComp In oDef.ReferenceComponents.ShrinkwrapComponents
		
		Dim oReferDoc As Document
        oReferDoc = oShrinkComp.ReferencedDocumentDescriptor.ReferencedDocument
		
		Dim oPropValue As String 
		oPropValue = oReferDoc.PropertySets.Item(4).Item("STRUCTURE SAVE DATE & TIME STAMP").Value
		
		oShrinkComp.SuppressLinkToFile = True
		
		iProperties.Value("Custom", "SHRINKWRAP SAVE DATE & TIME STAMP") = oPropValue
		
	Next
	
	
	'UPDATE SHRINKWRAP SAVE Date & TIME STAMP (CODE TEST 1)
	
	
	
	
	
	'UPDATE SHRINKWRAP SAVE DATE & TIME STAMP (CODE TEST 2)
	
	'Dim baseComponentFilePath As String
	
	'baseComponentFilePath = ThisDoc.Path + "\STRUCTURE ASSEMBLY.iam"
	
	'iProperties.Value("Custom", "SHRINKWRAP SAVE DATE & TIME STAMP") = iProperties.Value(baseComponentFilePath, "Custom", "STRUCTURE SAVE DATE & TIME STAMP")
	
	
End Sub

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes

kwalker1
Enthusiast
Enthusiast

Thanks Chandra.

 

The code you posted works because it obtains the date and time stamp before the base component is suppressed.

 

The problem I have is that I wish to check the base component's (STRUCTURE ASSEMBLY.iam) Save Date & Time Stamp custom iproperty before it is unsuppressed in the STRUCTURE ASSEMBLY (SHRINKWRAPPED).ipt file.

This is to determine whether the base component actually needs to be unsuppressed and updated or not.

 

To give some context as to why I'm trying to do this, I have multiple large sub-assemblies with large amounts of iLogic code set to run after opening document.

So I've shrinkwrapped these sub-assemblies for use in a full General Arrangement model but wish to ensure all the iLogic code in the sub-assemblies don't trigger automatically unless it is necessary.

Hence this is why the link to the base component is always suppressed in the shrinkwrap unless it is identified as needing an update.

 

Essentially I need to reference the suppressed base component's Save Date & Time Stamp custom iproperty without opening or unsuppressing it.

 

I've been trying various pieces of code but can't seem to get it to work.

I think I might be getting closer with this code but keep getting the error:

Could not find file 'C:\Users\kwalker\AppData\Local\Temp\c2uo3tfu.dll'.

 

Sub Main()
    
	shrinkwrapStamp = iProperties.Value("Custom", "SHRINKWRAP SAVE DATE & TIME STAMP")
	
	Dim baseComponentFilePath As String
	baseComponentFilePath = ThisDoc.Path + "\STRUCTURE ASSEMBLY.iam"
	
	Dim baseComponentFile As Document
	baseComponentFile = baseComponentFilePath
	
	Dim invDoc As Document
    invDoc = ThisApplication.Document.baseComponentFile
	
    ' Get the user defined property set.
    Dim invCustomPropertySet As PropertySet
    invCustomPropertySet = invDoc.PropertySets.Item("Inventor User Defined Properties")
	
    ' Get the part number property.
    Dim baseComponentStamp As Properties
    baseComponentStamp = invCustomPropertySet.Item("STRUCTURE SAVE DATE & TIME STAMP")
	
	'MessageBox.Show(baseComponentStamp, "Title")
	
	If shrinkwrapStamp <> baseComponentStamp Then
		iLogicVb.RunRule("iLogic Rules")
	Else
		'OTHERWISE Do Nothing And End CODE
	End If
	
End Sub

Thank you for your help.

 

Regards,

Kurt.

0 Likes

chandra.shekar.g
Autodesk Support
Autodesk Support

@kwalker1,

 

Try below iLogic code to get custom iProperty of ShriknWrap assembly without opening it. Unfortunately, suppressed shrikwrap assembly is unable to get custom iProperty.

 

Note: iLogic code should be run in PartDocument which contains ShrinkWrapComponent.

Sub Main()
	
	Dim oShrinkwrap As PartDocument
	oShrinkwrap = ThisApplication.ActiveDocument
	
	Dim oDef As PartComponentDefinition
	oDef = oShrinkwrap.ComponentDefinition
	
	Dim oShrinkComp As ShrinkwrapComponent
	For Each oShrinkComp In oDef.ReferenceComponents.ShrinkwrapComponents
		
		Dim oReferDoc As Document
        oReferDoc = oShrinkComp.ReferencedDocumentDescriptor.ReferencedDocument
		
		Dim oPropValue As String 
		oPropValue = oReferDoc.PropertySets.Item(4).Item("STRUCTURE SAVE DATE & TIME STAMP").Value
		 MessageBox.Show(oPropValue, "Title")
		
	Next
End Sub

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes