ThisDoc.Save alternative

ThisDoc.Save alternative

dennis
Advisor Advisor
1,691 Views
7 Replies
Message 1 of 8

ThisDoc.Save alternative

dennis
Advisor
Advisor

WARNING: I am new at this.

Basics of my iLogic:  I have an assembly with a part that is duplicated several times via the Pattern command.  I have a parameter driving the number of times the part is duplicated, I called it "Quantity".  I can change that value and the pattern updates.  But when I go to call the save, I get that it can't save via a Parameter change.  I want it to go ahead and save so that the BOM will be correct.

Any suggestions?

 

0 Likes
Accepted solutions (1)
1,692 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable

do you have a sample of your file?

 

 

0 Likes
Message 3 of 8

dennis
Advisor
Advisor
'First establish a LOD view to work within

Dim doc as AssemblyDocument = ThisDoc.Document Dim oLOD As LevelOfDetailRepresentation Dim oAsmCompDef As ComponentDefinition oAsmCompDef = doc.ComponentDefinition Try oLOD = oAsmCompDef.RepresentationsManager.LevelOfDetailRepresentations.Item("iLogic").Activate(True) Catch Dim nLOD As LevelOfDetailRepresentation nLOD = oAsmCompDef.RepresentationsManager.LevelOfDetailRepresentations.Add("iLogic") oLOD = nLOD Finally oLOD = oAsmCompDef.RepresentationsManager.LevelOfDetailRepresentations.Item("iLogic").Activate(True) End Try
'Use the Form to change the number of parts in the pattern
If Quantity >= 1 Then Component.IsActive("Component Pattern 1:1")= True Angle=(360/Quantity) Else 'if zero is entered in the form, then suppress the pattern

Component.IsActive("Component Pattern 1:1")= False End If 'ThisDoc.Save This is commented out for now, since it doesn't work
0 Likes
Message 4 of 8

Mike.Wohletz
Collaborator
Collaborator

What if you end your code with a doc.save and not the ThisDoc.Save since you have the Doc at the very top of your code. I understand the reason for it not working as it is more of a safety feature since this can run several times depending on how it is wired up to operate. I dont know if it will work but it is worth a shot. 

 

 

0 Likes
Message 5 of 8

dennis
Advisor
Advisor

I tried your suggestion Mike.  Still no joy.

I first added to the end of the code shown, but it acts like nothing is happening...no error msg either.

I then tried writing a second rule:

 

Dim doc as AssemblyDocument = ThisDoc.Document
Doc.Save

And called the second rule at the end of the first...and it still doesn't save it. If I run the second rule manually, it does save.

0 Likes
Message 6 of 8

Mike.Wohletz
Collaborator
Collaborator

Is the rule fired by a property change event? If so I think I had seen a form why not just set the rule to run only by adding a button to run it in the form and then the error should go away I would think. 

 

0 Likes
Message 7 of 8

dennis
Advisor
Advisor

Yes, I use a form to change the Quantity of the Pattern.  The form only changes the quantity value.  In the first Rule, I also divide 360/Quantity to get a different angle based on the number/quantity.  The pattern updates perfectly.  But when I go to check the BOM, it says I must save the assembly.  When I use the ThisDoc.Save in the iLogic, it gives me the "Can't use a parameter change as an Event".  So, I am trying to come up with a way to work around that limitation.  I am beginning to think there is no work around.

0 Likes
Message 8 of 8

xiaodong_liang
Autodesk Support
Autodesk Support
Accepted solution

Hi Dennis,

 

This is an as designed behavior. The help has indicated:

 

Save

Saves the currently active document. This function does not work in a rule triggered by a parameter change event.

Syntax

ThisDoc.Save  

http://help.autodesk.com/view/INVNTOR/2014/ENU/?guid=GUID-5B9FD675-28B2-4D2F-9A64-AFB08CB935D0

 

You need to manually run the iLogic rule with Save. Or, if the user closes the document, Inventor will ask for saving because the parameter changing and any other changes would cause document dirty.

0 Likes