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: 

Ilogic before ''save as'' command

5 REPLIES 5
Reply
Message 1 of 6
s_sanders
427 Views, 5 Replies

Ilogic before ''save as'' command

I want to fire a Ilogic rule in a ipt template, when i use the event ''before save'' the rule is not fired because the first save is the save as command. 

 

The rule get the extended dimensions of a plate, and creates a custom iproperty and filename.

 

 

5 REPLIES 5
Message 2 of 6
johnsonshiue
in reply to: s_sanders

Hi! Please share the file here so forum experts can take a look. It should be doable.

Many thanks!

 



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
Message 3 of 6
s_sanders
in reply to: johnsonshiue

Now i have run the next codes through a form

ThisDoc.Document.Rebuild()
On Error Resume Next
Dim oDoc As PartDocument
oDoc = ThisApplication.ActiveEditDocument
Dim CadlineSheetMetal As SheetMetalComponentDefinition
CadlineSheetMetal = oDoc.ComponentDefinition
CadlineSheetMetal.FlatPattern.Delete
CadlineSheetMetal.Unfold
Cadline = ThisApplication.ActiveDocument.ComponentDefinition
X= 10*( Cadline.RangeBox.MaxPoint.X - Cadline.RangeBox.MinPoint.X)
Y= 10*( Cadline.RangeBox.MaxPoint.Y - Cadline.RangeBox.MinPoint.Y)
Z= 10*( Cadline.RangeBox.MaxPoint.Z - Cadline.RangeBox.MinPoint.Z)
Parameter.Quiet = True
THICKNESS = MinOfMany(X, Y, Z)
LENGTH = MaxOfMany(X, Y, Z)
If X < LENGTH Then
WIDTH = X
End If
If Y < LENGTH Then
WIDTH = Y
End If
If Z < LENGTH Then
WIDTH = Y
End If
iProperties.Value("Custom", "Lengte") = Round(LENGTH, 0)
iProperties.Value("Custom", "Breedte") = Round(WIDTH, 0)
iProperties.Value("Custom", "Dikte") = Round(THICKNESS, 0)
Parameter("Lengte") = Round(LENGTH, 0)
Parameter("Breedte") = Round(WIDTH, 0)
Parameter("Dikte") = Round(THICKNESS, 0)
RuleParametersOutput()
iLogicVb.UpdateWhenDone = True
oDoc = ThisApplication.ActiveDocument
CadlineSheetMetal = oDoc.ComponentDefinition
InventorVb.DocumentUpdate()
ThisDoc.Save
iLogicVb.RunRule("Part number naam")

Second running this:

iProperties.Value("Project", "Part Number") = "PLAAT " & CStr(Lengte) & "x" & CStr(Breedte) & "x" & CStr(Dikte)
ThisDoc.Document.DisplayName = iProperties.Value("Project", "Part Number") & iProperties.Value("Project", "Project") & ".ipt"
ThisApplication.CommandManager.ControlDefinitions.Item("AppIsometricViewCmd").Execute
ThisApplication.CommandManager.StartCommand(CommandIDEnum.kFileSaveCommand)

Can this codes be combined? And fired by the save and save as command?

 

Thanks in advance

 

Message 4 of 6
MjDeck
in reply to: s_sanders

@s_sanders , do you want the rule to set the initial filename when you save for the first time after creating the part from the template?
It seems that the overall size of a part could change in future, but the filename would still display the initial size.


Mike Deck
Software Developer
Autodesk, Inc.

Message 5 of 6
s_sanders
in reply to: MjDeck

 


@MjDeck wrote:

@s_sanders , do you want the rule to set the initial filename when you save for the first time after creating the part from the template?
It seems that the overall size of a part could change in future, but the filename would still display the initial size.



Only set the initial filename is ok for us.

Message 6 of 6
MjDeck
in reply to: s_sanders

The problem is that the Before Save Document event happens *after* you see the Save As dialog. So you don't get a chance to set the filename in a rule on Before Save.
If seems like you have to set the display name before you save. Maybe the way you're doing it now (running from a form) is the best way.


Mike Deck
Software Developer
Autodesk, Inc.

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

Post to forums  

Autodesk Design & Make Report