Update and save assembly through ilogic in Drawing

Update and save assembly through ilogic in Drawing

Anonymous
Not applicable
1,762 Views
4 Replies
Message 1 of 5

Update and save assembly through ilogic in Drawing

Anonymous
Not applicable

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

0 Likes
1,763 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
I am using Inventor 2013 Product design suite with SP2
0 Likes
Message 3 of 5

jdkriek
Advisor
Advisor

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

Anonymous
Not applicable

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

0 Likes
Message 5 of 5

Vladimir.Ananyev
Alumni
Alumni

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

0 Likes