01-16-2020
04:46 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
01-16-2020
04:46 AM
Sorry about that. My mistake. I didn't properly define the MeasureTools. I left out the "= ThisApplication.MeasureTools" at the end of that line. I didn't take the time to test the code before posting it last time.
Here's the working version.
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 = ThisApplication.MeasureTools
Dim oTLL As Double
oTLL = oMeasure.GetLoopLength(oFace.EdgeLoops.Item(1)) '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 If
Wesley Crihfield
(Not an Autodesk Employee)