Loop value on iproperties

Loop value on iproperties

Anonymous
Not applicable
848 Views
9 Replies
Message 1 of 10

Loop value on iproperties

Anonymous
Not applicable

Hi, it's possible to get the loop's value on custom iproperties like the image below?loop.jpg

849 Views
9 Replies
Replies (9)
Message 2 of 10

WCrihfield
Mentor
Mentor

There are multiple ways to get that information into the Custom iProperties.

  • You could manually enter it within that Custom tab of the iProperties
  • If the value you want is already a Parameter in your Fx Parameters dialog box, then within the Parameters dialog box, you could click on the Export Parameter checkbox in its row.  This automatically copies it to the Custom iProperties.
  • You could use an iLogic rule to transfer that data to the Custom iProperties

Can you please be more informational as to what you need?

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 10

Anonymous
Not applicable
I would like to use a ilogic rule to get it automatically on custom iproperties
0 Likes
Message 4 of 10

WCrihfield
Mentor
Mentor

Would this work for you then?

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
Dim oTLL_Prop As [Property] = oCustPropSet.Add(oTLL,"Total Loop Length")

If this solves your problem, please "Accept As Solution".

Or if it helps you along the way to achieving your goal, please click "Like".

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 5 of 10

cassiano.godoy
Explorer
Explorer

I'm having the same problem and can't solve it.

0 Likes
Message 6 of 10

WCrihfield
Mentor
Mentor

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. 👍

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 7 of 10

Anonymous
Not applicable

Hi, thanks for help me, this didn't work.

erro.jpg

 

=/

Message 8 of 10

WCrihfield
Mentor
Mentor

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

EESignature

(Not an Autodesk Employee)

Message 9 of 10

Anonymous
Not applicable

Sorry, I didn't work, when the value appears on the custom iproperties the value was wrong.

0 Likes
Message 10 of 10

WCrihfield
Mentor
Mentor

You may need to convert the value to your local document units.  By default, any Double type values that are returned from iLogic's built-in measurement functions, are always given in the "Database Units" for that type of measurement. The "Database Units" used for Length measurements is always Centimeters, instead of the units specified within the Document Settings.  That's just how iLogic is set up, and that can't be changed.  However, you can convert the returned values by which ever means you prefer.  You can simply include some extra math in your code to compensate for the unit differences, or you can use Inventor's built-in unit converter.

 

Here is an updated version of that code, in which I am converting the units to Inches, instead of leaving them in default Centimeters.  I've also included the Perimeter measurement, to show the difference (when applicable).

If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kPartDocumentObject Then
	MsgBox("A Part Document must be active for this rule to work. Exiting.", vbOKOnly + vbCritical, "WRONG DOCUMENT TYPE")
	Exit Sub
End If
Dim oPDoc As PartDocument = ThisApplication.ActiveDocument
Dim oCustPropSet As PropertySet = oPDoc.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 oPerimeter, oOther, oTLL As Double

For Each oEL As EdgeLoop In oFace.EdgeLoops
	If oEL.IsOuterEdgeLoop Then
		'<<< This doesn't accound for interior holes or cutouts >>> 
		oPerimeter = oMeasure.GetLoopLength(oEL)
	Else
		oOther = oOther + oMeasure.GetLoopLength(oEL)
	End If
Next
oTLL = (oPerimeter + oOther)

'Convert the Database Units (Centimeters) to Inches
'oPerimeter = (oPerimeter / 2.54)
'oOther = (oOther / 2.54)
'or
oPerimeter = ThisApplication.UnitsOfMeasure.ConvertUnits(oPerimeter, UnitsTypeEnum.kDatabaseLengthUnits, UnitsTypeEnum.kInchLengthUnits)
oOther = ThisApplication.UnitsOfMeasure.ConvertUnits(oOther, UnitsTypeEnum.kDatabaseLengthUnits, UnitsTypeEnum.kInchLengthUnits)

'the measured units have already been converted now, so the math with be in Inches
oTLL = (oPerimeter + oOther)

oAns = MsgBox("Perimiter = " & oPerimeter & vbCrLf & _
"Other Interior Loop Lengths = " & oOther & vbCrLf & _
"Total Loop Length = " & oTLL & vbCrLf & _
"Do you want to write the Total Loop Length value to iProperties? ", vbYesNo + vbQuestion + vbDefaultButton2, " TOTAL LOOP LENGTH ")
If oAns = vbNo Then
	Exit Sub
ElseIf oAns = vbYes Then
	'checking if that iProperty already exists or if it needs to be created
	Dim oExists As Boolean 'False by default
	For Each oProp As Inventor.Property In oCustPropSet
		If oProp.Name = "Total Loop Length" Then
			oProp.Value = oTLL
			oExists = True
		End If
	Next
	If oExists = False Then
		oCustPropSet.Add(oTLL, "Total Loop Length")
	End If
End If

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click 'LIKE' 👍.

If you have time, please... Vote For My IDEAS 💡and Explore My CONTRIBUTIONS

Inventor 2021 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes