Push User text parameter from parent part into derived part

Push User text parameter from parent part into derived part

pranaykapse1
Contributor Contributor
630 Views
4 Replies
Message 1 of 5

Push User text parameter from parent part into derived part

pranaykapse1
Contributor
Contributor

I have the NOZ_Number text user parameter in the parent part file.

pranaykapse1_0-1680008454389.png

But I could use only numeric values in the derived part, not the text parameters.

pranaykapse1_1-1680008596065.png

Could you help me to get those text user parameters into the derived part

pranaykapse1_2-1680008703380.png

 

0 Likes
631 Views
4 Replies
Replies (4)
Message 2 of 5

WCrihfield
Mentor
Mentor

Hi @pranaykapse1.  That ability (and several others related to text type parameters) has been requested for a long time.  There are ways of pushing those text type parameters to the other document, but not as derived parameters, not in that same grouping of parameters, and not as truly 'linked' parameters.  They would just be static user parameters, and you would need to set up an extra mechanism to keep them updated when changes are made to the source document.  Below are some (but not all) links to ideas posted in the Inventor Ideas forum, where people are requesting for these abilities to be added to Inventor.  You can vote for them to help get them implemented by Autodesk sooner, but no guarantees.  The first one listed below, which is the best match for your request, has been 'accepted', but apparently not 'implemented' yet.  More votes may help get it implemented sooner, but when it does, it will likely be in a newer version of Inventor.

https://forums.autodesk.com/t5/inventor-ideas/we-need-to-be-able-to-derive-text-parameters/idi-p/115... 

https://forums.autodesk.com/t5/inventor-ideas/ability-to-link-all-parameter-types/idi-p/7304077 

https://forums.autodesk.com/t5/inventor-ideas/export-text-parameter/idi-p/3817276 

https://forums.autodesk.com/t5/inventor-ideas/model-states-capture-text-parameters-in-the-model-stat... 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 5

pranaykapse1
Contributor
Contributor

Thank you for the information @WCrihfield.

is it possible to get the name of the parent part like here N1-1 and put this text to the child part user parameter?

pranaykapse1_0-1680071571723.png

 

0 Likes
Message 4 of 5

WCrihfield
Mentor
Mentor

Hi @pranaykapse1.  I know how to copy a parameter from the 'active' part on my screen, which has another part derived into it, to that derived in part.  And I know how to copy a parameter from a part that is derived into my 'active' part, to the 'active' part on my screen.  But that is only possible when the 'link' (dependency) to the derived in part has not been suppressed or broken.  But the other part (the part that is derived into this one) does not know that it it associated with 'this' part in any way, because it will not contain anything pointing to 'this' part.  So, you could not start with that derived in part as the 'active' one on your screen, then copy a parameter to the part that it is derived into.  Similar to a part not knowing that it is being used in a hundred assemblies, because there is nothing in the part that tells it about those hundred assemblies.  If you need to start your code from the part that is being derived into other stuff, then you could probably just include the FullFileName (or FullDocumentName) of the 'other' part that this one is being derived into within your code, so you have a reference to work from, then just use standard API code to open that part and copy a parameters from this one in to that one if you wanted to.

 

Below is an example of copying a parameter from 'this' part into a part that is derived into 'this' one.

'Explanation:  ThisDoc is a Part with another Part derived into it
'This rule will copy a UserParameter from this part, to the derived in part
If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kPartDocumentObject Then
	MsgBox("A Part Document must be active for this rule to work. Exiting.", vbCritical, "")
	Exit Sub
End If
Dim oPDoc As PartDocument = ThisDoc.Document
Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition
Dim oUParam As UserParameter = oPDef.Parameters.UserParameters.Item("MyTxtParam1")

Dim oDPCs As DerivedPartComponents = oPDef.ReferenceComponents.DerivedPartComponents
Dim oDP As DerivedPartComponent = oDPCs.Item(1)
Dim oDPDoc As PartDocument = oDP.ReferencedDocumentDescriptor.ReferencedDocument
Dim oDUParams As UserParameters = oDPDoc.ComponentDefinition.Parameters.UserParameters
Dim oDUParam As UserParameter = Nothing
Try
	oDUParam = oDUParams.Item(oUParam.Name)
Catch
	oDUParam = oDUParams.AddByValue(oUParam.Name, oUParam.Value, oUParam.Units)
End Try

And below is an example of copying a parameter from the part that is derived into 'this' part, into 'this' part.

'Explanation:  ThisDoc is a Part with another Part derived into it
'This rule will copy a UserParameter from the derived in part into 'this' one
If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kPartDocumentObject Then
	MsgBox("A Part Document must be active for this rule to work. Exiting.", vbCritical, "")
	Exit Sub
End If
Dim oPDoc As PartDocument = ThisDoc.Document
Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition
Dim oUParams As UserParameters = oPDef.Parameters.UserParameters

Dim oDPCs As DerivedPartComponents = oPDef.ReferenceComponents.DerivedPartComponents
Dim oDP As DerivedPartComponent = oDPCs.Item(1)
Dim oDPDoc As PartDocument = oDP.ReferencedDocumentDescriptor.ReferencedDocument
Dim oDUParams As UserParameters = oDPDoc.ComponentDefinition.Parameters.UserParameters
Dim oDUParam As UserParameter = oDUParams.Item("MyTextParam1")

Dim oUParam As UserParameter = Nothing
Try
	oUParam = oUParams.Item(oDUParam.Name)
Catch
	oUParam = oUParams.AddByValue(oDUParam.Name, oDUParam.Value, oDUParam.Units)
End Try

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

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 5

pranaykapse1
Contributor
Contributor

Thank you @WCrihfieldso much for all this information and the code. but it is not working on my computer.

I just wanted to push the "Nozzle_Number" custom iproperty value from the Parent part to the derived child part.

I have attached both the part file. It will be great if you help me with this.

pranaykapse1_0-1680165924042.png

 

0 Likes