User Parameters in Properties

User Parameters in Properties

tcaG6GZK
Contributor Contributor
1,178 Views
9 Replies
Message 1 of 10

User Parameters in Properties

tcaG6GZK
Contributor
Contributor

Hello friends

I have searched the forum, but unfortunately found nothing - I hope you are not angry with me if I ask a question that may already be answered.

I have created a few user parameters with lists. Then I made a form so that the user can select the appropriate values there.

Now I want that the selected values are written in certain iProperties, so that these can be read out then also e.g. in the drawing.

What does the code look like? I think it should be an iLogic routine that is executed when saving.

thanks a lot for the info.

 

Cheeers

Tom

0 Likes
1,179 Views
9 Replies
Replies (9)
Message 2 of 10

JelteDeJong
Mentor
Mentor

Maybe I understand you wrong but this is possible without any iLogic code. Try the following:

Go to your parameter overview and make sure that your parameter is exported.

JelteDeJong_1-1669279110110.png

Then go to your iProperties and notice that your parameter is automatically added as a custom iProperty.

JelteDeJong_2-1669279220898.png

But if you want it in a standard iProperty you type a formula that will insert the value in your iProperty.

JelteDeJong_3-1669279329623.png

 

 

 

 

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 3 of 10

tcaG6GZK
Contributor
Contributor

Hi Jelte

thx for your reply!!!

but i have no such parameters

tcaG6GZK_0-1669279623199.png

i can not klick on export - there is nothing to choose.

 

i have texparameters with a list.

 

thx in advance

Tom

0 Likes
Message 4 of 10

JelteDeJong
Mentor
Mentor

In that case you can use iLogic. Try a rule like this:

iProperties.Value("Project", "Description") = MyTextParameter

"Project" is the tab in the iProperties window, 

"Description" is the property name as is in the iProperty window,

MyTextParameter (without the double quotes!) is your parameter name

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 5 of 10

tcaG6GZK
Contributor
Contributor

Hi Jelte

 

you´re amazing!! Thanks - it works.

 

may I ask you another question?? Is it possible to see in a Form the BOM Structure of a part so I can choose it or change it?? That would help a lot!!

thx in advance

 

Tom

0 Likes
Message 6 of 10

m.krom
Contributor
Contributor
'Dim kDefaultBOMStructure As Integer = 51969 ''The Default Structure type.
'kInseparableBOMStructure 51974 The inseparable Structure type.
'kNormalBOMStructure 51970 The normal Structure type.
'kPhantomBOMStructure 51971 The phantom Structure type.
'kReferenceBOMStructure 51972 The reference Structure type.
'kPurchasedBOMStructure 51973 The purchased Structure type.
''***END INFO***

Dim oDoc As Document
oDoc = ThisDoc.Document

If oDoc.DocumentType <> kPartDocumentObject Then
	MessageBox.Show("Not a Part Document", "Document Type")

	
Else If oDoc.DocumentType = kPartDocumentObject Then	

	Dim oDocCompDef As PartComponentDefinition
		oDocCompDef = oDoc.ComponentDefinition
		
End If
			

If oDoc.ComponentDefinition.BOMStructure = 51970 Then
		MessageBox.Show("Normal", "BOM Type")

Else If oDoc.ComponentDefinition.BOMStructure = 51973 Then
		MessageBox.Show("Inkoop", "BOM Type")
	
Else If oDoc.ComponentDefinition.BOMStructure = 51972 Then
		MessageBox.Show("Reference", "BOM Type")

Else If oDoc.ComponentDefinition.BOMStructure = 51971 Then
		MessageBox.Show("Phantom", "BOM Type")
	
End If
0 Likes
Message 7 of 10

m.krom
Contributor
Contributor
'Dim kDefaultBOMStructure As Integer = 51969 ''The Default Structure type.
'kInseparableBOMStructure 51974 The inseparable Structure type.
'kNormalBOMStructure 51970 The normal Structure type.
'kPhantomBOMStructure 51971 The phantom Structure type.
'kReferenceBOMStructure 51972 The reference Structure type.
'kPurchasedBOMStructure 51973 The purchased Structure type.
''***EINDE INFO***

Dim oDoc As Document
oDoc = ThisDoc.Document

If oDoc.DocumentType <> kAssemblyDocumentObject Then
	MessageBox.Show("Not an Assembly document", "Document Type")

Else If oDoc.DocumentType = kAssemblyDocumentObject Then
	Dim oAssyCompDef As AssemblyComponentDefinition
			oAssyCompDef = oDoc.ComponentDefinition
End If


If oDoc.ComponentDefinition.BOMStructure = 51970 Then
	MessageBox.Show("Normal", "BOM Type")

Else If oDoc.ComponentDefinition.BOMStructure = 51973 Then
	MessageBox.Show("Inkoop", "BOM Type")
	
Else If oDoc.ComponentDefinition.BOMStructure = 51972 Then
	MessageBox.Show("Reference", "BOM Type")

Else If oDoc.ComponentDefinition.BOMStructure = 51971 Then
	MessageBox.Show("Phantom", "BOM Type")
	
Else If oDoc.ComponentDefinition.BOMStructure = 51974 Then
	MessageBox.Show("Inseperable", "BOM Type")
	
End If
0 Likes
Message 8 of 10

m.krom
Contributor
Contributor

Imports Inventor.UnitsTypeEnum

'Dim kDefaultBOMStructure As Integer = 51969 ''The Default Structure type.
'kInseparableBOMStructure 51974 The inseparable Structure type.
'kNormalBOMStructure 51970 The normal Structure type.
'kPhantomBOMStructure 51971 The phantom Structure type.
'kReferenceBOMStructure 51972 The reference Structure type.
'kPurchasedBOMStructure 51973 The purchased Structure type.


Dim oPartDoc As Document
oPartDoc = ThisDoc.Document

If oPartDoc.DocumentType <> kPartDocumentObject Then
MessageBox.Show("This is not a part document", "Document type")
End If

If oPartDoc.DocumentType = kPartDocumentObject Then

Dim oPartCompDef As PartComponentDefinition
oPartCompDef = oPartDoc.ComponentDefinition

Dim oParams As Parameters
oParams=oPartCompDef.Parameters

Dim oUserParams As UserParameters
oUserParams=oParams.UserParameters

Try
otester = oUserParams.Item("BOMs")
Catch
oInsulationType=oUserParams.AddByValue("BOMs", "Normal", kTextUnits)
MultiValue.SetList("BOMs", "Normal", "Phantom", "Reference", "Purchaced")
End Try
End If

iLogicVb.UpdateWhenDone = True

Dim MYCHOISE As String = InputListBox("Make a choise...", MultiValue.List("BOMs"), BOMs, Title := "PART BOM", ListName := "List")

If MYCHOISE = "Purchaced" Then
oPartDoc.ComponentDefinition.BOMStructure = BOMStructureEnum.kPurchasedBOMStructure


Else If MYCHOISE = "Normal" Then
oPartDoc.ComponentDefinition.BOMStructure = BOMStructureEnum.kNormalBOMStructure


Else If MYCHOISE ="Phantom" Then
oPartDoc.ComponentDefinition.BOMStructure = BOMStructureEnum.kPhantomBOMStructure


Else If MYCHOISE ="Reference" Then
oPartDoc.ComponentDefinition.BOMStructure = BOMStructureEnum.kReferenceBOMStructure


End If

oPartDoc.ComponentDefinition.Parameters.Item("BOMs").delete

iLogicVb.UpdateWhenDone = True

0 Likes
Message 9 of 10

WCrihfield
Mentor
Mentor

Hi guys. Just dropping a couple tips/pointers in here.

If you want to be able to select a variation from the BOMStructureEnum from a list to then apply to the BOMStructure property of the active document via iLogic, the following is likely the simplest way to do that. With this, you do not even need to create a multi-value parameter, because its creates it own list, shows it to the user so they can choose one, then sets the chosen value to the document, all using just 3 lines of code.

Dim oBOMStrTypes As List(Of String) = System.Enum.GetNames(GetType(Inventor.BOMStructureEnum)).Cast(Of String).ToList
Dim oChosenBOMStrType As String = InputListBox("Prompt", oBOMStrTypes)
ThisDoc.Document.ComponentDefinition.BOMStructure = System.Enum.Parse(GetType(BOMStructureEnum), oChosenBOMStrType)

As for the Text type and Boolean type multi-value user parameters that you would like to create custom iProperties for...the fact that there is no checkbox for exporting them in the Parameters dialog box has been a thorn in our sides for a great many years, and there are several methods for dealing with that situation floating around out there. Generally when I create them, I am planning on using them in an iLogic rule for helping to control something, and I pretty much always want them to have a custom iProperty counterpart too, so I personally have an iLogic rule that I use to iterate through every user parameter, which checks if its units are 'Text' or 'Boolean', and if so, makes sure there is a custom iProperty to match it, with the same value. And I have that iLogic rule listed under the event named 'Any User Parameter Change' within the Event Triggers dialog box, on both the 'Parts' and 'Assemblies' tabs, so that these values will always stay accurate, without me having to think about it. There are a couple examples of codes like this in the article I wrote back in 2019 (link below).

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

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 10 of 10

m.krom
Contributor
Contributor

Thanks for the tips. very helpful. 

 

Greetings from the Netherlands

0 Likes