01-15-2020
07:41 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
01-15-2020
07:41 AM
Perhaps if I added a MessageBox question, and a check for that iProperty at the end like this.
Dim oDoc As PartDocument = ThisApplication.ActiveDocument
Dim oCustPropSet As PropertySet = oDoc.PropertySets.Item("Inventor User Defined Properties")
Dim oFace As Face = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select a Part Face.")
Dim oMeasure As MeasureTools
Dim oTLL As Double = oMeasure.GetLoopLength(oFace.Edges) 'oTLL is short for Total Loop Length
oAnswer = MessageBox.Show("Total Loop Length = " & oTLL & vbNewLine &
"Do you want To write this value To iProperties ? ", " TOTAL Loop LENGTH ", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)
If oAnswer = vbNo Then
Return
ElseIf oAnswer = vbYes Then
'The following checks to see if that iProperty already exists.
'In case you have already ran this rule before on the same document.
Dim oExists As Boolean = False
For Each oProp As [Property] In oCustPropSet
If oProp.Name = "Total Loop Length" Then
oExists = True
End If
Next
If oExists = False Then
oCustPropSet.Add(oTLL, "Total Loop Length")
ElseIf oExists = True Then
oCustPropSet.Item("Total Loop Length").Value = oTLL
End If
End IfDoes this work for you?
If this solves your problem, please click 'Accept As Solution'.
Or if this helps you along the way to reaching your goal, please click the 'Like' button. ![]()
Wesley Crihfield
(Not an Autodesk Employee)