Numeric parameter show up as text in iProperties

Numeric parameter show up as text in iProperties

gert-leonvanlier
Collaborator Collaborator
783 Views
5 Replies
Message 1 of 6

Numeric parameter show up as text in iProperties

gert-leonvanlier
Collaborator
Collaborator

I am having troubles with 'exporting' parameters to iProperties. I use the following iLogic rule:

iProperties.Value("Custom", "InclineAngle") = InclineAngle
iProperties.Value("Custom", "HeightIn") = HeightIn
iProperties.Value("Custom", "HeightOut") = HeightOut
iProperties.Value("Custom", "FloatingHeight") = FloatingHeight

Select Case Bidirectional
Case True
	iProperties.Value("Custom", "Bidirectional") = "Yes"
Case False
	iProperties.Value("Custom", "Bidirectional") = "No"
End Select

iProperties.Value("Custom", "NominalSpeed") = ""
iProperties.Value("Custom", "PowerCalculated") = ""  
iProperties.Value("Custom", "PowerUsed") = ""

 

I have several numeric parameters that show up as number in the iProperties except for some, which show as text. When I switch to number in the iProperties windows, the values appear, but when my iLogic code has been running, I am back to square one. The values HeightIn and HeightOut for example are showing up as they should (as number).

 

F3YCNpyIyd.png

 

They are marked as numeric (speed [m/s] and power [kW], official unit types) in the parameters:

Inventor_XUOeBpQTfg.png

Even when I change the unit type for example to mm the outcome stays the same.

 

What goes wrong or am I doing wrong here? Is there a way to specify the type when running my iLogic rule?

 

0 Likes
784 Views
5 Replies
Replies (5)
Message 2 of 6

k14348
Advocate
Advocate

Hi,

iProperties.Value("Custom", "InclineAngle") = InclineAngle
iProperties.Value("Custom", "HeightIn") = HeightIn
iProperties.Value("Custom", "HeightOut") = HeightOut
iProperties.Value("Custom", "FloatingHeight") = FloatingHeight

Select Case Bidirectional
Case True
	iProperties.Value("Custom", "Bidirectional") = "Yes"
Case False
	iProperties.Value("Custom", "Bidirectional") = "No"
End Select

iProperties.Value("Custom", "NominalSpeed") =0
iProperties.Value("Custom", "PowerCalculated") =0
iProperties.Value("Custom", "PowerUsed") =0

 

Hope your issue solved.

-Karth

 

0 Likes
Message 3 of 6

WCrihfield
Mentor
Mentor

It looks like all you're doing is transfering your Parameters to iProperties, correct?

You don't need any code to do this with numerical Parameters.

  • Open your Parameters dialog box.
  • Check the check-box in the Export column of the Parameters you want to link to the iProperties.
  • Then right-click anywhere on that same row, and choose "Custom Property Format..."
  • In that dialog box:
    • Under Property Type, choose Number from the drop-down list.
    • Choose the Units you want (usually doesn't matter with number format, because Units String option is greyed out)
    • Choose the Precision you want
    • If you want the same format used for all other parameters marked to Export, check the box for "Apply to existing comparable parameters".
    • Click OK.
  • Click Done on your Parameters window.

Now open your iProperties dialog, go to the Custom tab, and they should all be there, in the format you chose.

 

I hope this helps.
If this solves your problem, or answers your questions, please click 'Accept As Solution".
Or, if this helps you reach your goal, please click 'LIKES" 👍.

 

Also, if you're interested, here are a few of the 'Ideas' I'd like to get implemented.
If you agree with any of them, please vote for them.

  • Add more capabilities to the 'Customize' dialog box (exe. Add Tab & Add Panel) Click Here
  • MessageBox, InputBox, and InputListBox Size & Format Options Click Here
  • Constrain & Dimension Images In Assembly Sketches & Drawing Sketches (TitleBlocks & SketchedSymbols) Click Here
  • Save Section View Status In DesignViewRepresentation (So It Can Be Used In The Drawing) Click Here
  • Add SolidBodies Folder In iLogic Rule Editor Model Tab Click Here
  • Convert All Views To Raster Before Autosave Stores To 'OldVersions' Folder Click Here
  • SetDesignViewRepresentation - Fix limitations for DrawingView of a Part Click Here
  • Create DocumentSubTypeEnum Click Here

Inventor 2020 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 4 of 6

WCrihfield
Mentor
Mentor

You will need code to copy Text or Boolean (Yes No) type parameters to your iProperties.

You can use the following code to do that.

 

Export All Text & Boolean Type Parameters To Custom iProperties Using iLogic

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 6

gert-leonvanlier
Collaborator
Collaborator

@WCrihfield wrote:

It looks like all you're doing is transfering your Parameters to iProperties, correct?


Correct.

 


@WCrihfield wrote:

You don't need any code to do this with numerical Parameters.

  • Open your Parameters dialog box.
  • Check the check-box in the Export column of the Parameters you want to link to the iProperties.
  • Then right-click anywhere on that same row, and choose "Custom Property Format..."
  • In that dialog box:
    • Under Property Type, choose Number from the drop-down list.
    • Choose the Units you want (usually doesn't matter with number format, because Units String option is greyed out)
    • Choose the Precision you want
    • If you want the same format used for all other parameters marked to Export, check the box for "Apply to existing comparable parameters".
    • Click OK.
  • Click Done on your Parameters window.

Now open your iProperties dialog, go to the Custom tab, and they should all be there, in the format you chose.


This I knew, but since we have lots of models I don't want to open each model from the Vault, checking out, check all the necessary boxes in the parameters and then checking the model back in. Eventually I want this done automatically using a external iLogic rule.

 

Why is the type even set to text when it is clearly a number?

 

But, if it is possible to use iLogic to check the boxes in the parameter list and set the type to number it's fine. The text and boolean parameters can be done then using my code.

 

 

0 Likes
Message 6 of 6

WCrihfield
Mentor
Mentor

Here is some code for an external iLogic rule that will look at all Model Parameters, all User Parameters, and all Custom iProperties, no matter which type of document it is.  For each Parameter, it checks to see if there is a Custom iProperty with the same name.  If it finds one, it copies the Parameter's value to the value of the Property.  If it doesn't find the Property, it creates it, with the same name and value as the Parameter.  For Model Parameters, I put an additional check in there, to see if it has been renamed.  Most people don't use Model Parameters for automation & programming purposes, but if they do, they usually at least rename it, and when they rename it, they usually avoid starting its name with "d", because that's how Inventor names them by default.  So if the Model Parameter's name doesn't start with "d" it is then processed the same as the User Parameters.

 

You should be able to use this to process older files.  If you use this code in it's own Sub, as part of a larger code to process files in bulk, you may have to change from ActiveDocument to a different specified oDoc type variable.

Dim oDocType As DocumentTypeEnum = ThisApplication.ActiveDocumentType

Dim oPDoc As PartDocument
Dim oPDef As PartComponentDefinition
Dim oADoc As AssemblyDocument
Dim oADef As AssemblyComponentDefinition
Dim oParams As Parameters
Dim oDDoc As DrawingDocument
Dim oCProps As PropertySet
Dim oProp As [Property]
Dim oExists As Boolean

If oDocType = DocumentTypeEnum.kPartDocumentObject Then
	oPDoc = ThisApplication.ActiveDocument
	oPDef = oPDoc.ComponentDefinition
	oParams = oPDef.Parameters
	oCProps = oPDoc.PropertySets.Item("Inventor User Defined Properties")
ElseIf oDocType = DocumentTypeEnum.kAssemblyDocumentObject Then
	oADoc = ThisApplication.ActiveDocument
	oADef = oADoc.ComponentDefinition
	oParams = oADef.Parameters
	oCProps = oADoc.PropertySets.Item("Inventor User Defined Properties")
ElseIf oDocType = DocumentTypeEnum.kDrawingDocumentObject Then
	oDDoc = ThisDrawing.Document
	oParams = oDDoc.Parameters
	oCProps = oDDoc.PropertySets.Item("Inventor User Defined Properties")
End If

Dim oMParams As ModelParameters = oParams.ModelParameters
Dim oMParam As ModelParameter
Dim oUParams As UserParameters = oParams.UserParameters
Dim oUParam As UserParameter

For Each oUParam In oUParams
	'Check if matching Custom iProperty exists. If not create it.
	oExists = False
	For Each oProp In oCProps
		If oProp.Name = oUParam.Name Then
			oProp.Value = oUParam.Value
			oExists = True
		End If
	Next
	If oExists = False Then
		oCProps.Add(oUParam.Value, oUParam.Name)
	End If
Next

For Each oMParam In oMParams
	'Checks to see if it has been renamed (Model Params always start with "d" then a number)
	'If it has been renamed, it is probably important
	If Left(oMParam.Name, 1) <> "d" Then
		'Check if matching Custom iProperty exists. If not create it.
		oExists = False
		For Each oProp In oCProps
			If oProp.Name = oMParam.Name Then
				oProp.Value = oMParam.Value
				oExists = True
			End If
		Next
		If oExists = False Then
			oCProps.Add(oMParam.Value, oMParam.Name)
		End If
	End If
Next
	

Also, here is a fairly helpful link to another post that shows creating different Types or iProperties.

https://forums.autodesk.com/t5/inventor-customization/need-to-retrieve-type-data-of-custom-iproperti... 

 

I hope this helps.
If this solves your problem, or answers your questions, please click 'Accept As Solution".
Or, if this helps you reach your goal, please click 'LIKES" 👍.

 

Also, if you're interested, here are a few of the 'Ideas' I'd like to get implemented.
If you agree with any of them, please vote for them.

  • Add more capabilities to the 'Customize' dialog box (exe. Add Tab & Add Panel) Click Here
  • MessageBox, InputBox, and InputListBox Size & Format Options Click Here
  • Constrain & Dimension Images In Assembly Sketches & Drawing Sketches (TitleBlocks & SketchedSymbols) Click Here
  • Save Section View Status In DesignViewRepresentation (So It Can Be Used In The Drawing) Click Here
  • Add SolidBodies Folder In iLogic Rule Editor Model Tab Click Here
  • Convert All Views To Raster Before Autosave Stores To 'OldVersions' Folder Click Here
  • SetDesignViewRepresentation - Fix limitations for DrawingView of a Part Click Here
  • Create DocumentSubTypeEnum Click Here

Inventor 2020 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes