iLogic rule to mark parameter as exported

iLogic rule to mark parameter as exported

Anonymous
Not applicable
1,793 Views
4 Replies
Message 1 of 5

iLogic rule to mark parameter as exported

Anonymous
Not applicable

I am looking for an iLogic code to mark a specific user parameter in each part and subassembly to key, export, and set the "custom property type" under the equation column to be fractional instead of decimal with 1/32" precision in one all encompassing assembly (that way I don't have to run this code in each individual part, just once in the main assembly). The parameter is called PARTLENGTH and I have kind of a general code idea here:

 

'Dim oDoc As AssemblyDocument
Dim oDoc As PartDocument = ThisDoc.Document 'of : oDoc as AssemblyDocumment = ThisDoc.Document

'nummerieke parameter
Try
prop = oDoc.ComponentDefinition.Parameters.UserParameters.item ("PARTLENGTH")
Catch
End Try

param =Parameter.Param("PARTLENGTH") 
param.ExposedAsProperty = True 

'param.CustomPropertyFormat.Precision = kThreeDecimalPlacesPrecision 
param.CustomPropertyFormat.ShowTrailingZeros = False 
param.CustomPropertyFormat.ShowLeadingZeros = False 
param.CustomPropertyFormat.ShowUnitsString = False 
'param.CustomPropertyFormat.Units = "in" 




How close is this rule to being correct? I'm afraid to run it

 

Accepted solutions (1)
1,794 Views
4 Replies
Replies (4)
Message 2 of 5

MechMachineMan
Advisor
Advisor
Make a test document and try er out!

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 3 of 5

Milan_Nosil
Advocate
Advocate

It works! Thank you very much 😉

0 Likes
Message 4 of 5

Anonymous
Not applicable

Hi. I have the same issue for user parameter. Would u shere the script w/ me?

0 Likes
Message 5 of 5

WCrihfield
Mentor
Mentor
Accepted solution

@Anonymous 

Are you looking for something like this?

Dim oDocType As DocumentTypeEnum = ThisApplication.ActiveDocumentType
Dim oParams As Parameters
If oDocType = DocumentTypeEnum.kPartDocumentObject Or _
	oDocType = DocumentTypeEnum.kAssemblyDocumentObject Then
	oParams = ThisApplication.ActiveDocument.ComponentDefinition.Parameters
ElseIf oDocType = DocumentTypeEnum.kDrawingDocumentObject Then
	oParams = ThisDrawing.Document.Parameters
End If
Dim oUParams As UserParameters = oParams.UserParameters
Dim oUParam As UserParameter
Dim oParamName As String = "Param_Name"
'Dim oParamName As String = InputBox("Enter a parameter name.","","")
Dim oExists As Boolean 'false by default
For Each oUParam In oUParams
	If oUParam.Name = oName Then
		oExists = True
		oUParam.IsKey = True
		oUParam.ExposedAsProperty = True
		Dim oCPF As CustomPropertyFormat = oUParam.CustomPropertyFormat
		oCPF.PropertyType = Inventor.CustomPropertyTypeEnum.kNumberPropertyType
		oCPF.Units = Inventor.UnitsTypeEnum.kInchLengthUnits
		oCPF.Precision = Inventor.CustomPropertyPrecisionEnum.kEightDecimalPlacesPrecision
		'oCPF.Precision = Inventor.CustomPropertyPrecisionEnum.kSixteenthsFractionalLengthPrecision
	End If
Next
If oExists = False Then
	MsgBox("That parameter was not found.",,"")
End If

 

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

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

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

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes