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.
Hi! Please share the file here so forum experts can take a look. It should be doable.
Many thanks!
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
@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.
@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.
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.
Can't find what you're looking for? Ask the community or share your knowledge.