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

iLogic Help-Need Code to Auto Rebuild when Assembly is Saved

kkruegerWZZH4
Participant

iLogic Help-Need Code to Auto Rebuild when Assembly is Saved

kkruegerWZZH4
Participant
Participant

Hey guys! 

 

I recently started dipping my toes in to the iLogic coding in Inventor and I can't figure out how to get the active assembly to "Rebuild All" (including all components within the assembly) any time I save the assembly. These aren't huge assemblies as I have multiple layers to my models, but these are template assemblies that will be copied and resized for different conditions and I need certain aspects (like the bolted connections and links) to update automatically when someone who isn't me is trying to use these. The last thing we need is for someone to miss clicking rebuild and our fastener counts/assembly lengths to be off. 

 

Other rebuild triggers are an option (such as opening or placing the assembly within another assembly) but having it happen when it is saved is my preference. Also I am running Inventor 2019 in case that is relevant.

 

Thanks in advance!

0 Likes
Reply
Accepted solutions (1)
1,161 Views
5 Replies
Replies (5)

AdamAG99T
Advocate
Advocate
Accepted solution

The Ilogic code to rebuild an assembly is simply

ThisDoc.Document.Rebuild()

I would recommend saving this as an external rule and setting up your assembly templates so that they have the rule set to trigger before saves. You can also set this trigger on existing documents.

Screenshot_12.png

 

kkruegerWZZH4
Participant
Participant

What is the reason you recommend saving it as an external rule rather than a rule in the document? Where would the external rule be saved? If it is on my desktop, wouldn't someone else who doesn't have the rule saved to their computer get an error when they try to use the assembly?


@AdamAG99T wrote:

I would recommend saving this as an external rule and setting up your assembly templates so that they have the rule set to trigger before saves. You can also set this trigger on existing documents.

 


 

0 Likes

AdamAG99T
Advocate
Advocate

If you're using this for multiple users then yes you could save it as a regular rule on the assembly template. The main benefit of using an external rule would be to make it easier to add to previously made documents, since you would just need to add the trigger instead of creating a new rule in each document as well as the trigger. 

kkruegerWZZH4
Participant
Participant

OK, so I ended up running into some issues in my overall model where the sub assemblies are placed-

Similar assemblies share some parts (small purchased parts such as clips that are the same regardless of where they are used) and they get into a cyclical Rebuild/Update/Save loop where it won't allow me to check in my overall because one sub-assembly will rebuild, making it so the other needs to be updated because of the shared parts, and so on.

 

So I am taking a different approach that should work but I can't figure out why it wont.

If Assembly_Length <> Assembly_Length

	ThisDoc.Document.Rebuild()
	
End If

 

This code SHOULD rebuild if the parameter "Assembly_Length" changes, correct? I have a skeleton .ipt linked to the assembly, and this Assembly_Length is pulling the Length from the .ipt, so when I update the length of the skeleton and return to the Assembly, the Assembly_Length will change and the rebuild code should trigger. 

 

I can't figure out why this isn't working!! It seems so simple.

taylorjonesXGNK9
Explorer
Explorer

Wanting to re-open this, attempting to do the same thing more or less. 

What solutions did you land upon/was behaviour as expected? I'm currently running:

ThisDoc.Document.Rebuild()


To no success, unsure why that is the case. 

0 Likes