Accessing parameters from parts in an assembly

Accessing parameters from parts in an assembly

Anonymous
Not applicable
704 Views
4 Replies
Message 1 of 5

Accessing parameters from parts in an assembly

Anonymous
Not applicable

From the posts I’ve found here, it seems that when I place a part into an assembly I should be able to access that part’s parameters.  Unfortunately, I’m having some problems doing that.  With some parts it works fine, but with others it seems like it is only looking in the assembly parameters not in the part specified.  All parts were placed the same way, and I used the same code to try an access the parameters from both parts.  My code is below:

 

Placing parts:
Dim oAssemblyDoc As AssemblyDocument = ThisDoc.Document

Dim oComponentDef As ComponentDefinition = oAssemblyDoc.ComponentDefinition

Dim oMatrix As Matrix = ThisApplication.TransientGeometry.CreateMatrix 

 

Dim oPlaceCap As ComponentOccurrence = oComponentDef.Occurrences.Add("C:\VaultWork\Documents\Common\944A0112_BUTTWELD_PIPE_CAP\944A0112H10.ipt", oMatrix)

Dim oDLPipeCapOccurance As String = "DropLegPipeCap:1" 

Dim oPlaceCoupling As ComponentOccurrence = oComponentDef.Occurrences.Add("C:\VaultWork\Documents\Common\COUPLING\944A0044H05.ipt", oMatrix)

Dim oDLCouplingOccurance As String = "DropLegDrainCouping:1" 

 

Getting parameters from the parts:

oPipeCapHeight = Parameter(oDLPipeCapOccurance, "OAHCap")

oCouplingLength = Parameter(oDLCouplingOccurance, "LENGTH")

(Both “OAHCap” and “LENGTH” are parameters in their respective parts.  Getting the “LENGTH” parameter from the coupling part works without any issues, but I cannot get “OAHCap” from the pipe cap part. I get an error saying not found, and it looks like it is only looking in the assembly, which does not have that parameter.)

 

One thing I noticed was that in the box at the top for the parts that allow me to access the parameters, under the occurrence the parameters are there, but for the parts that do not, they aren’t.  Is there some setting or something that is blocking that?  Both I, and our CAD administrator have looked over the part files and can’t really see anything different about them, but we don’t really know what to be looking for, either. (Also I just saw when taking this screen shot, the symbols next to the parts are different, I'm sure that also has something to do with it)iLogicSS.JPG

I’m also open to work-arounds.  I thought maybe I could just open the part, make it active, and then save the parameter I want to a variable that I can use after the part is closed, but so far I have been unable to make that work either.

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

Anonymous
Not applicable

Did a little more digging and it appears that the part that isn't working says it is a DerivedBody rather than a Solid (solid part is working).  So I guess I need to find a way to access the parameters of the base part.

0 Likes
Message 3 of 5

chandra.shekar.g
Autodesk Support
Autodesk Support

@Anonymous,

 

Hoping that below iLogic code would help to get parameter from derived body. To more investigation, can you please provide sample files? please make sure that files are non confidential one.

 

Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisApplication.ActiveDocument

Dim oAsmDef As AssemblyComponentDefinition
oAsmDef = oAsmDoc.ComponentDefinition

Dim oLeafOccs As ComponentOccurrencesEnumerator
oLeafOccs = oAsmDef.Occurrences.AllLeafOccurrences

Dim oDoc As Document
Dim oOcc As ComponentOccurrence

Dim izhod As String

For Each oOcc In oLeafOccs
	Try
     	oDoc = oOcc.Definition.Document
		If Not TypeOf oDoc Is PartDocument Then
			Continue For
		End If
 	Catch
 		Continue For
 	End Try 

	Try
		If oDoc.ComponentDefinition.ReferenceComponents.DerivedPartComponents.Count > 0  Then
			Dim derComp As DerivedPartComponent
			Try
				derComp = oDoc.ComponentDefinition.ReferenceComponents.DerivedPartComponents(1)
				Dim oParam as Parameter 
				oParam = derComp.Parameters.Item("OAHCap")
				
				oPipeCapHeight = oParam.Value
			Catch:End Try
			
		ElseIf 	oDoc.ComponentDefinition.ReferenceComponents.DerivedAssemblyComponents.Count > 0 Then
			Dim derComp As DerivedAssemblyComponent
			Try
				derComp = oDoc.ComponentDefinition.ReferenceComponents.DerivedAssemblyComponents(1)
				Dim oParam as Parameter 
				oParam = derComp.Parameters.Item("OAHCap")
				
				oPipeCapHeight = oParam.Value
			Catch:End Try  
		End If
		
	Catch:End Try
Next

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 4 of 5

Anonymous
Not applicable

Thanks.

I gave it a shot, but it had and error that " 'ComponentOccurence' is not defined.

I have a feeling this code, if I got it to run, would probably have the same problem solution I tried did.  The derived part is a member from an iPart factory.  When the code gets the reference info, it is getting it from the factory and not the specific member.  

I'm starting to think the best thing I can do is just hard code in the possible values I want and go from there, every work around I try still runs into a wall.

0 Likes
Message 5 of 5

chandra.shekar.g
Autodesk Support
Autodesk Support

@Anonymous,

 

For further investigation, can you please provide sample assembly with same iPart? Samples need not be original one. It can be replicate of same assembly.

 

Please make sure that files are non confidential.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes