Get name of derived parameter reference parameter

Get name of derived parameter reference parameter

daniel.puchta
Enthusiast Enthusiast
1,817 Views
12 Replies
Message 1 of 13

Get name of derived parameter reference parameter

daniel.puchta
Enthusiast
Enthusiast

Hi,

I need to change the reference of derived parameter table from one document to another with the same names of model parameters to which it will be linked to. Unfortunatelly it is not working by simply changing the reference file so the sollution is to firstly delete original derived parameter table, and then create new derived parameter table with reference to a new document.

The problem is, I cannot get the original name of parameter from which the derived parameter was created. It is easy to do it manually - right click on derived parameters table in Parameters window and then select Edit Folder (see attached image).

It is any method to get original names via iLogic/VBA (dirrectly or indirectly by workarround)?

 

derived parameters.png

 

Thank you a lot!

0 Likes
Accepted solutions (1)
1,818 Views
12 Replies
Replies (12)
Message 2 of 13

JhoelForshav
Mentor
Mentor

Hi @daniel.puchta 

You can find the derived parameters through the definition of your DerivedPartComponent

See example below:

The code looks through the available parameters as DerivedPartEntities, checks if they're included and if so gets the name and expression of the DerivedPartEntiys referenced entity (the parameter in the document you're deriving from)

 

Dim oDoc As PartDocument = ThisDoc.Document
Dim oPars As String = "Parameters: "

For Each oPar As DerivedPartEntity In oDoc.ComponentDefinition.ReferenceComponents.DerivedPartComponents.Item(1).Definition.Parameters
	If oPar.IncludeEntity Then oPars = oPars & vbCrLf & oPar.ReferencedEntity.Name & " : " & oPar.ReferencedEntity.Expression
Next
MsgBox(oPars)
0 Likes
Message 3 of 13

daniel.puchta
Enthusiast
Enthusiast

I can not because my part is not derived part. If I open VBA Editor, more specifically Locals Window, I have no object in DerivedPartComponents. (see picture)

My parameter Table was created by opening Inventor Parameter window, clicking on Link button and selecting .ipt file and then from that file parameters.

 

danielpuchta_0-1629192295919.png

 

0 Likes
Message 4 of 13

JhoelForshav
Mentor
Mentor

Hi @daniel.puchta 

Are you linking parameters to an assembly or a part? If it's to an assembly you can go through the referenced entity of the linked parameters like this:

Dim oDoc As Document = ThisDoc.Document
Dim oParams As String = "Parameters: "
For Each oParam As DerivedParameter In oDoc.ComponentDefinition.Parameters.DerivedParameterTables.Item(1).LinkedParameters
	oParams = oParams & vbCrLf & oParam.ReferencedEntity.Name & " : " & oParam.ReferencedEntity.Expression
Next
MsgBox(oParams)

I don't know why referenced entity is nothing when I use the same code in a part though, but it is and therefore it doesn't work... But on the other hand, in a part you can just as well derive the parameters instead and then you can use the code I posted previously 🙂

Message 5 of 13

daniel.puchta
Enthusiast
Enthusiast

Thank you, the code for assemblies is working. But I have problems with parts. I tried code you mentioned and it is still not working.

I attached the parts.

0 Likes
Message 6 of 13

JhoelForshav
Mentor
Mentor
Accepted solution

@daniel.puchta 

I believe it's a bug in the Inventor API that ReferencedEntity is always Nothing for linked parameters within a part. Maybe @MjDeck can bring some clarity to this?

 

Within a part however you can derive parameters instead of using "Link". Then the code below should work:

Dim oDoc As PartDocument = ThisDoc.Document
Dim oPars As String = "Parameters: "

For Each oPar As DerivedPartEntity In oDoc.ComponentDefinition.ReferenceComponents.DerivedPartComponents.Item(1).Definition.Parameters
	If oPar.IncludeEntity Then oPars = oPars & vbCrLf & oPar.ReferencedEntity.Name & " : " & oPar.ReferencedEntity.Expression
Next
MsgBox(oPars)

To derive parameters, click derive in your part that you want to include the parameter in:

derive1.PNG

 

Then select the part you want to derive the parameter(s) from and select the parameter(s) you want to include.

 

derive2.PNG

0 Likes
Message 7 of 13

daniel.puchta
Enthusiast
Enthusiast
Thank you,

i hope that this bug will be solved. In the meantime I will be using Derive Part tool.
Message 8 of 13

MjDeck
Autodesk
Autodesk

@JhoelForshav , there does seem to be a bug in DerivedParameter.RefererencedEntity. I'm taking a look at it.

 

@daniel.puchta , you can replace the part reference in the DerivedParameterTable if the replacement part is a "saved as" copy of the original. Can you work with that restriction?


Mike Deck
Software Developer
Autodesk, Inc.

Message 9 of 13

MjDeck
Autodesk
Autodesk

The DerivedParameter.ReferencedEntity bug has internal number INVGEN-55601.


Mike Deck
Software Developer
Autodesk, Inc.

Message 10 of 13

daniel.puchta
Enthusiast
Enthusiast

Thank you I hope that this bug will not be hard to solve 🙂

0 Likes
Message 11 of 13

leszeko
Contributor
Contributor

Is it any progress on it? It's been almost a year since this was reported and I can not see any changes in 2022 version. Was it updated in 2013 version?

0 Likes
Message 12 of 13

MjDeck
Autodesk
Autodesk

The problem has been fixed this year. The fix will be in next year's release : Inventor 2024.


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 13 of 13

leszeko
Contributor
Contributor

It's really  good to hear. Thank you Mike.

0 Likes