ilogic rule - run one time and delete itself after run

ilogic rule - run one time and delete itself after run

tegstette
Advocate Advocate
1,970 Views
4 Replies
Message 1 of 5

ilogic rule - run one time and delete itself after run

tegstette
Advocate
Advocate

Hi

 

I wonder if there is a way to make the rule delete itself after it has run...?

 

E.g. I have a template .ipt and this has a local ilogic rule that adds a custom property triggered on save. But I only want it to run once, and delete itself after?

 

Is there a snippet I can add at the end of the ilogic rule to do this?

Best regards
TG

Autodesk Inventor/Vault Professional 2021
0 Likes
1,971 Views
4 Replies
Replies (4)
Message 2 of 5

salariua
Mentor
Mentor

Don't know how to do that but on a similar note I am running a form when user saves the drawing, but only the first time, not with every save. So I am checking if the file has a path, meaning if it's been saved.

 

 

trigger = iTrigger0

Dim oPath As String
oPath = ThisDoc.PathAndFileName(False)

'if path does not exist, file not saved
If oPath.IsNullOrWhiteSpace(oPath)
	iLogicForm.ShowGlobal("iProps", FormMode.NonModal)
Else
	'MessageBox.Show("document saved", "ilogic")
End If

 

 

2015-05-14_15-03-15.png

Adrian S.
blog.ads-sol.com 

AIP2012-2020 i7 6700k AMD R9 370
Did you find this reply helpful ?
If so please use the Accepted Solutions or Like button - Thank you!
Message 3 of 5

VdVeek
Advocate
Advocate

This line Deletes the rule with name "Rule1". When run from the same rule that needs to be deleted it gives an error, but the rule is deleted. So make a copy before testing this Smiley Wink

 

 

iLogicVb.Automation.DeleteRule(ThisApplication.ActiveDocument, "Rule1")

Rob

Autodesk Inventor 2015 Certified Professional & Autodesk Inventor 2012 Certified Professional.
Message 4 of 5

jdkriek
Advisor
Advisor

Why not trigger an external rule? Then you won't need to delete it. Or better yet, via that external iLogic rule check if the property is created and depending on if that answer is yes or no, either create the propety or end the rule. It's simple to add that little extra logic. Take into account someone deleting that custom property in the future, ect.

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


Message 5 of 5

Anonymous
Not applicable

Hey Jonathon, I have a similar issue that has stumped me regarding the placement of view labels that are autofilled using a custom iproperty. Your code works brilliantly but i have made a slight adaption to suit my labels. As I use a grid system to track views I have added some co-ordinates to your rule that picks up the location of the view label.

 

The big issue is that after running the rule every view label has the same grid number as the first view. I believe that this could be due to the iproerty lacking in the ability to hold than one value. Do you think that I could run the rule to update the label / sketched symbol one time only and not relay back to the original? Or could I add an additional prompted entry to replace the iproperty?

 

Here is the sketched symbol, grid and rule. I would appreciate any help you could offer here as I have hit a wall!!

 

View Label_Grid.PNG

 

SyntaxEditor Code Snippet


Dim
oDoc As DrawingDocument oDoc = ThisDoc.Document Dim oSheets As Sheets oSheets = oDoc.Sheets Dim oSheet As Sheet Dim oViews As DrawingViews Dim oView As DrawingView Dim oSymbol As SketchedSymbol Dim oSymbols As SketchedSymbols 'iterate through all of the sheets For Each oSheet In oSheets 'remove existing sketched symbols named View Label For Each oSymbol In oSheet.SketchedSymbols If oSymbol.Definition.Name = "DD" Then oSymbol.Delete Else End If Next 'set sheet active oSheet.Activate 'set a refernce to the drawing views collection oViews = oDoc.ActiveSheet.DrawingViews ' Iterate through all of the views For Each oView In oViews 'This places a sketched symbol with the name "View_Label" Dim oSymDef As SketchedSymbolDefinition 'defind the sketch symbol to be inserted oSymDef = oDoc.SketchedSymbolDefinitions.Item("DD") 'set a string array with values for the prompted entries found in the symbol Dim sPromptStrings(1) As String sPromptStrings(0) = "SCALE " & oView.ScaleString 'set to view scale sPromptStrings(1) = oView.Name 'set to view name 'set the position for the sketched symbol to be inserted ' and spaced off of the selected view center Dim oPosition As Point2d: oPosition = oView.Center oPosition.y = oPosition.y - (oView.Height / 2 + .6) oPosition.x = oPosition.x - (oView.Width / 2 + .6) 'insert the sketched symbol and set the prompted entries oSymbol = oSheet.SketchedSymbols.Add(oSymDef, oPosition,0,1,sPromptStrings) Dim posX As Double = oPosition.x * 10 Dim posY As Double = oPosition.y * 10 Dim xTrue As Boolean = False Dim yTrue As Boolean = False If posX > 10 And posX < 41.667 Then xTrue = True iProperties.Value("Custom", "Grid_No") = "1" End If If posY > 10 And posY < 34.75 Then yTrue = True iProperties.Value("Custom", "Grid_Letter") = "A" End If If posX > 41.667 And posX < 71.333 Then xTrue = True iProperties.Value("Custom", "Grid_No") = "2" End If If posY > 34.75 And posY < 57.5 Then yTrue = True iProperties.Value("Custom", "Grid_Letter") = "B" End If If posX > 71.333 And posX < 101 Then xTrue = True iProperties.Value("Custom", "Grid_No") = "3" End If If posY > 57.5 And posY < 80.25 Then yTrue = True iProperties.Value("Custom", "Grid_Letter") = "C" End If ' If xTrue And YTrue Then 'MessageBox.Show("X: " & Posx.ToString() & " " & "Y: " & Posy.ToString()) ' End If Next Next 'activate sheet1 oDoc.Sheets.Item(1).Activate

 

0 Likes