Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
WCrihfield
in reply to: cassiano.godoy

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 If

Does 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. :thumbs_up:

Wesley Crihfield

EESignature

(Not an Autodesk Employee)