Message 1 of 9
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I'm trying to retrieve a dimension in a drawing view using API. The dimension is is within a derived part:
The code I am using successfully finds the sketch in 'Pt1.ipt' but crashes when I try to create a geometry proxy of the dimension.
I have attached the drawing (and models) and the code can be found in the 'retrieve dim from assy rule'. I've also posted it below.
'get the view
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)
Any help would be appreciated,
thanks,
John
Solved! Go to Solution.