Derived parameter table

Derived parameter table

vishnuteja_srikanti
Participant Participant
248 Views
4 Replies
Message 1 of 5

Derived parameter table

vishnuteja_srikanti
Participant
Participant

i have derived parameters of part occurance in assembly fx parameters as shown below 

 

now i want to add derive few more parameters from same derived parameter table using vb.net code 

any idea how can i execute this?

 

i used below code to add parameter table in assembly doc 

ptable = pAsmDoc.ComponentDefinition.Parameters.DerivedParameterTables.Add2(comp_flnmae, pretricol)

now i want to derive few more parameters from same parameter table .

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

WCrihfield
Mentor
Mentor

Hi @vishnuteja_srikanti.  When using that DerivedParameterTables.Add2 method, it gives you the DerivedParameterTable object that it created.  But if coming back later, you would just have to find that same DerivedParameterTable that you created again, so that you can use its DerivedParameterTable.LinkedParameters property.  That is a Read/Write property, with an ObjectCollection type value.  So, first collect all the parameters from that source document that you want to Link to this one into an ObjectCollection, then set that as the value of this property.  By the way, if you have multiple DerivedParameterTables, and need to know which one is for which source document, I believe you can use the DerivedParameterTable.ReferencedDocumentDescriptor property, then its DocumentDescriptor.FullDocumentName property, or its DocumentDescriptor.ReferencedDocument property.  If attempting to go the DerivedParameterTable.ReferenceComponent route, that is not talking about a regular assembly component (ComponentOccurrence ), but something (ReferenceComponent type object) that was 'derived into' the current document, resulting in these parameters getting included.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 5

C_Haines_ENG
Collaborator
Collaborator

Conveniently, I JUST wrote a method to do this. You can select a dimension in a sub component of an assembly and it will link it to the assembly you are in. 

 

Sub Main

	Dim oDoc As Document = ThisDoc.Document

	Dim oLinkDim As DimensionConstraint = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kSketchDimConstraintFilter, "Select Dimension")

	Dim oLinkPath As String = oLinkDim.Parameter.Parent.FullFileName

	Dim oDocParams As Parameters = oDoc.ComponentDefinition.Parameters
	Dim oLinkedTable As DerivedParameterTable = CheckIfLinked(oDocParams, oLinkPath)

	Call LinkParameter(oLinkDim.Parameter, oLinkedTable)

End Sub

Function CheckIfLinked(oDocParams As Parameters, oLinkPath As String)

	For Each oDerivedTable As DerivedParameterTable In oDocParams.DerivedParameterTables

		If oDerivedTable.ReferencedDocumentDescriptor.FullDocumentName = oLinkPath Then Return oDerivedTable

	Next

	Return oDocParams.DerivedParameterTables.Add(oLinkPath)

End Function

Sub LinkParameter(oNewParam As Parameter, oLinkedTable As DerivedParameterTable)

	Dim oCollect As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection

	For Each oLinkedParam As DerivedParameter In oLinkedTable.LinkedParameters
		oCollect.Add(oLinkedParam.ReferencedEntity)
	Next

	oCollect.Add(oNewParam)

	oLinkedTable.LinkedParameters = oCollect

End Sub

 

0 Likes
Message 4 of 5

vishnuteja_srikanti
Participant
Participant

hello haines 

 

i actually tried this method for first time when you are adding params in derived table it is working fine later once you complete the process and for next time it is showing unspecified error 

 

in below code i have created 2 object collections plink params is which dumps parameters into derived parameter table and also collect already listed parameters in derived parameters table and pretricol is collection of new parameters which i want to add with linked parameters in same table so this how i wrote is anything i am missing 

 

actually the same worked fine until i complete process for first time after when i close form and again run the same code for other component operation i am having this error

 

vishnuteja_srikanti_0-1750391405573.png

 

0 Likes
Message 5 of 5

C_Haines_ENG
Collaborator
Collaborator

Change:

 

plinkparam.add(pParma)

to

plinkparam.add(pParma.ReferencedEntity)

 

when getting parameters from a derivedparameter table, they are derived parameters and Inventor wont accept adding them back in like that as you would be adding a link to a link. Get the ReferencedEntity to get the actual Parameter to add it back in.