Drawing retrieve dimension from derived part in an assembly

Drawing retrieve dimension from derived part in an assembly

johnster100
Collaborator Collaborator
240 Views
0 Replies
Message 1 of 1

Drawing retrieve dimension from derived part in an assembly

johnster100
Collaborator
Collaborator

Hi,

I am trying to retrieve a dimension from an assembly occurrence. The occurrence part is a solid derived through from a multi solid body part, the sketch dimension i'm trying to retrieve is in this multi solid part.

 

I've attached a drawing and model files to show what i mean. The rule is in the drawing - called 'retrieive dim from assy'.

 

The issue i have is my code crashes when i try to create a geometry proxy for the dimension constraint object.

 

it is a very similar problem to these two articles:

https://adndevblog.typepad.com/manufacturing/2016/03/retrieve-sketch-dimension-of-part-document-insi...

https://adndevblog.typepad.com/manufacturing/2015/08/retrieve-sketch-dimension-of-part-document-insi...

 

Any help would be appreciated,

thanks,

John

 

	Dim oView As Inventor.DrawingView = ActiveSheet.View("VIEW1").View

	'get the assembly document
	Dim oAssy As Inventor.AssemblyDocument = oView.ReferencedDocumentDescriptor.ReferencedDocument

	'get the assembly component definition
	Dim oAssyCompDef As Inventor.AssemblyComponentDefinition = oAssy.ComponentDefinition

	'get the first occurrence in the assembly
	Dim oCC As Inventor.ComponentOccurrence = oAssyCompDef.Occurrences.Item(1)

	'get the part document from the occurrence
	Dim oPart As Inventor.PartDocument = oCC.ReferencedDocumentDescriptor.ReferencedDocument

	'get the part component definition
	Dim oPartCompDef As Inventor.PartComponentDefinition = oPart.ComponentDefinition

	'get the collection of derived comps
	Dim oRefComps As Inventor.ReferenceComponents = oPartCompDef.ReferenceComponents

	'get the first ref doc
	Dim oRefDoc As Inventor.PartDocument = oRefComps.DerivedPartComponents.Item(1).ReferencedDocumentDescriptor.ReferencedDocument

	Dim oDC As Inventor.DimensionConstraint = oRefDoc.AttributeManager.FindObjects(, , "TEST").Item(1)
	MsgBox(oDC.Parameter.Name) 'check we have the parameter
	 
	'create the object collection
	Dim oObjColl As Inventor.ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
	
	Dim oDCProxy As Object
	oCC.CreateGeometryProxy(oDC, oDCProxy)

	'add the dim to the collection
	oObjColl.Add(oDCProxy)

	Dim oSheet As Inventor.Sheet = ActiveSheet.Sheet
	oSheet.DrawingDimensions.GeneralDimensions.Retrieve(oView, oObjColl)

 

 

0 Likes
241 Views
0 Replies
Replies (0)