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: 

Update and save assembly through ilogic in Drawing

4 REPLIES 4
Reply
Message 1 of 5
vince_123
1562 Views, 4 Replies

Update and save assembly through ilogic in Drawing

Hi, 

 

I am new to Inventor and as a part of automating manufacturing drawings, am trying to include ilogic code in the drawing , that would accept values from the user and store it as "user parameters" and make corresponding changes in the inventor drawing file.

 

So, to replicate my issue on a smaller scale, i had created 2 parts and created an assembly out of these 2 parts. I used the assembly in my drawing.

 

In the Drawing i created a user parameter .. say "external_param". I am opening the drawing and changing the value of the user parameter through the (Fx) parameter table. 

doc = ThisDoc.Document

If external_param >= 50 And external_param <= 99 Then
Parameter("block_1.ipt.d0") = 15 'change the length of the block
Parameter("block_1.ipt.d14") = 3 'change the number of holes in the block

ElseIf external_param >= 100 And external_param <= 199 Then
Parameter("block_1.ipt.d0") = 40
Parameter("block_1.ipt.d14") = 5

ElseIf external_param >= 200 And external_param <= 299 Then
Parameter("block_1.ipt.d0") = 80
Parameter("block_1.ipt.d14") = 6

ElseIf external_param >= 300 And external_param <= 399 Then
Parameter("block_1.ipt.d0") = 160
Parameter("block_1.ipt.d14") = 9
End If


RuleParametersOutput()
iLogicVb.UpdateWhenDone = True
'InventorVb.DocumentUpdate()

 

 

As you can see, i have commented out InventorVb.DocumentUpdate() , im not quite sure what would accomplish the update and save of the assembly document in the background (without prompting for a save/update). I have also tried thisDoc.Save and thisdoc.update. Using these 2 commands along with the InventorVb.DocumentUpdate() or iLogicVb.UpdateWhenDone caused Inventor to Crash.

 

 

What am i missing? Could I get some assistance in the right direction . Thanks!

 

Vince

4 REPLIES 4
Message 2 of 5
vince_123
in reply to: vince_123

I am using Inventor 2013 Product design suite with SP2
Message 3 of 5
jdkriek
in reply to: vince_123

Look at the Document.Save2 Method in the API refrence (Help > Additional Resources > Programming Help)

 

Calling Document.Save2 without specifying any arguments results in the dirty dependents getting saved. The "Save Dependents" dialog is not displayed.

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 4 of 5
vince_123
in reply to: jdkriek

Many thanks for the help Jon, that worked!..

 

What i have done is...

 

1. Create a UI in VB .NET and accept values from the user.

2. Pass these values to the parameter tables in an Inventor drawing file that contains a "main_rule"

3. This main rule changes the assembly & part parameters of the model represented in the drawing.

 

I used triggers(for a model parameter change)  in the individual assembly and part files to do an

RuleParametersOutput()
InventorVb.DocumentUpdate()

in another rule resting in these indiviual files.

 

I have also added 

iLogicVb.RunRule(part/assembly,rulename)

in the main rule that is present in the drawing to call the resident rules in the assembly/ part files.

 

I get a feelin that im doing the same operation twice. if my understanding is correct, shouldn't the ilogicVb.RunRule line automatically run the rules in the assembly & part files without requiring an explicit Event trigger ?

 

regds,

Vince

Message 5 of 5

If you place a temporary call to MessageBox function (or MsgBox) in the beginning of the rule in assembly (or part) document you will be notified about every rule execution.  It seems from your description that this rule is executed twice (due to parameters changes and after RunRule call).


Vladimir Ananyev
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