iLogic Trigger for iAssemblies (rebuild/regenerate on save)

iLogic Trigger for iAssemblies (rebuild/regenerate on save)

mcgyvr
Consultant Consultant
1,078 Views
3 Replies
Message 1 of 4

iLogic Trigger for iAssemblies (rebuild/regenerate on save)

mcgyvr
Consultant
Consultant

iLogic newbie here (waves hand)

Can someone help me out with creating an iLogic rule? Autodesk won't fix the bugs so I need to do a workaround which I'm hoping ilogic can do for me.

This is what I need to happen.

When I save an assembly file (its the iassy factory if that matters) I need the following to happen.

#1-Perform a rebuild all

#2-Regenerate all members

#3-Save file.

 

There is a bug with iassemblies and design view reps not syncing until a rebuild all and generate members is performed. I was hoping that iLogic could be used to do this automatically instead of me.

 

Thanks in advance..



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
0 Likes
1,079 Views
3 Replies
Replies (3)
Message 2 of 4

mcgyvr
Consultant
Consultant

Ok..

I have found the code for the rebuild (below) but need the code to perform the generate files for the iassembly members.

ThisDoc.Document.Rebuild()


-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
0 Likes
Message 3 of 4

MjDeck
Autodesk
Autodesk

Here is some code to rebuild and then regenerate the iAssembly members in Inventor 2011.  Unfortunately, this isn't reliable if you run it on the Before Save Document event.  It will generate the members, but then it can fail to save the assembly!  So you should only run this manually.

 

 

doc = ThisDoc.Document
If (doc.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject) Then Return

doc.Rebuild()

Dim assemDoc as AssemblyDocument = doc
Dim compDef as AssemblyComponentDefinition = assemDoc.ComponentDefinition

If (Not compDef.IsiAssemblyFactory) Then Return

Dim factory As iAssemblyFactory = compDef.iAssemblyFactory

Trace.WriteLine("--- Generating members...")
For Each row As iAssemblyTableRow In factory.TableRows
  Trace.WriteLine(" --- Generating row: " & row.MemberName)
  factory.CreateMember(row)
Next
Trace.WriteLine("--- Done.")

 

 


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 4 of 4

mcgyvr
Consultant
Consultant

Well it works... But the failure to save issue makes me feel like I've fixed one workaround only to have to do another.

Any ideas to get this rule to trigger when a document is saved (before save) without it failing???



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
0 Likes