iLogic trigger on opening component

iLogic trigger on opening component

Walker2859
Participant Participant
295 Views
2 Replies
Message 1 of 3

iLogic trigger on opening component

Walker2859
Participant
Participant

I have a rule to set the dimensions of my component into custom iProperties, is there a way to make it so the rule is triggered when i enter a new component?

the current code is:

Sub Main()
Dim customPropertySet As Inventor.PropertySet
Dim prop As Inventor.Property
Dim propertyName As String
Dim propertyValue As String

customPropertySet = ThisDoc.Document.PropertySets.Item("Inventor User Defined Properties")

' Set custom property for d0
propertyName = "d0"
propertyValue = Measure.PreciseExtentsHeight
Try
    prop = customPropertySet.Item(propertyName)
Catch
    ' Assume error means not found
    customPropertySet.Add("", propertyName)
End Try
iProperties.Value("Custom", propertyName) = propertyValue

' Set custom property for d1
propertyName = "d1"
propertyValue = Measure.PreciseExtentsWidth
Try
    prop = customPropertySet.Item(propertyName)
Catch
    ' Assume error means not found
    customPropertySet.Add("", propertyName)
End Try
iProperties.Value("Custom", propertyName) = propertyValue

' Set custom property for d2
propertyName = "d2"
propertyValue = Measure.PreciseExtentsLength
Try
    prop = customPropertySet.Item(propertyName)
Catch
    ' Assume error means not found
    customPropertySet.Add("", propertyName)
End Try
iProperties.Value("Custom", propertyName) = propertyValue

End Sub
0 Likes
Accepted solutions (1)
296 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor
Accepted solution

What do you mean by "when i enter a new component"?  Are you talking about when you add an assembly component within an assembly?  If you are talking about a Document, instead of a component, then will this document be truly New (like if you clicked on the New command to create a new document), or do you just mean when you open an existing document, or something different?  If the document is truly new, it will not have any geometry to measure yet, and may throw an error when you try to measure its contents.  There is a way to trigger rules to run when certain events happen by using the Event Triggers dialog box, which you can reach on the Manage tab > iLogic panel.  Within that dialog you will see 5 tabs, and the one called "This Document" is usually the active one.  Stuff you do on that tab will only effect that one document.  Stuff you do on other tabs will effect all of those specific types of documents.  In this dialog you can drag rules from the left over to the right, under an event name, to cause that rule to run when that event happens.  Be careful with this though.  For instance, you don't want your rule to save the document, and set that rule to run when the document gets saved, because that will cause an endless cycle...just as an example.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 3

Walker2859
Participant
Participant
I did mean when I either entered a new assembly component or opened a new model. this does help. thankyou
0 Likes