Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Fast iLogic rule for multiple add participant feature in large assemblies

1 REPLY 1
Reply
Message 1 of 2
HTibagi
671 Views, 1 Reply

Fast iLogic rule for multiple add participant feature in large assemblies

Hi guys,

 

I usually work with very large assemblies (about 20 - 25 thousand parts), and sometimes have to use assembly features to cut some of the components.

 

The problem is that it takes forever to include lots of components to participate of that feature. You may be thinking that I should cut through all and them remove the components I don't want to cut, but I have tried this many times and my Inventor Pro 2014 crashed every time I tried.

 

So, I got some parts of codes here and there (I am pretty noob at iLogic programming, I am sorry), and I got this code that works, but much slower than what I wanted:

 

Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisApplication.ActiveDocument
    
Dim oDef As AssemblyComponentDefinition
oDef = oAsmDoc.ComponentDefinition
    
Dim oAssemblyFeatures As Features
oAssemblyFeatures = oDef.Features
    
Dim oAsyFeat As PartFeature
oAsyFeat = oAssemblyFeatures.ExtrudeFeatures.Item(1)
        
Dim compOcc As ComponentOccurrence
'InventorVb.DocumentUpdate(False)
'iLogicVb.UpdateWhenDone = True


Try
    For Each compOcc In oAsmDoc.SelectSet
        oAsyFeat.AddParticipant (compOcc)
    Next
Catch
	MessageBox.Show("Erro", "iLogic")
    Return
End Try

 

I know, it adds the selected componens ONLY to the first feature of the assembly. In my case, I have only one feature.

 

It takes so long time to run because of the update of the assembly on every loop of the For Each ... Next. I tried to include the two commented lines above, but when I did it, the rule stoped working!

 

I would like to stop updating the assembly and update after the rule concludes, that I thought  "iLogicVb.UpdateWhenDone = True" would do, but I don't know what I am doing wrong.

 

Any ideas?

 

Thank you very much!

1 REPLY 1
Message 2 of 2
philippe.leefsma
in reply to: HTibagi

You could try to use a global transaction, below is some VBA code that should also work in iLogic:

 

Public Sub RunGlobalTx()

    Dim Tx As Transaction
    Set Tx = ThisApplication.TransactionManager.StartGlobalTransaction( _
        ThisApplication.ActiveDocument, _
        "ADN")

    'do some stuff ...

    Tx.End
    
End Sub

 

Hope it helps,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report