Message 1 of 3
Automated Drawing Dimensions

Not applicable
07-20-2020
09:57 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
first time posting, so if i did anything wrong, feel free to correct me.
I am fairly new to Inventor 2020, but throught this forum I already managed to create a pretty beautiful Assembly and Drawing document. Now I want to add automated dimensions through attributes.
In the assemblies I want do draw and dimension there is always one attribute called "Rollt_Top" and one "Fuss_Bot". I am fairly certain, that my code is able to find them and to create a Proxy out of them. I also think that the geometry intent work as they should, but i am not 100% sure. However with addLinear(Point, Intent1, Intent2) I always get an error (HRESULT: 0x80004005 (E_FAIL)))
Here is my code:
Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
oSheet = oDoc.ActiveSheet
Dim oView As DrawingView
oView = oSheet.DrawingViews.Item(1)
'Reference the Assembly On that view
Dim oAssembly As AssemblyDocument
oAssembly = oView.ReferencedDocumentDescriptor.ReferencedDocument
Dim oGeneralDims As GeneralDimensions
oGeneralDims = oSheet.DrawingDimensions.GeneralDimensions
Dim Edge1 As Edge
Dim Edge2 As Edge
Dim oOccEdge1Proxy As EdgeProxy
Dim oOccEdge2Proxy As EdgeProxy
'Find the Model referenced in the Assembly
For Each oRef In oAssembly.AllReferencedDocuments
oModelDoc = oRef
Try
'Find Face 1 on the model
Dim oObjs1 As ObjectCollection
oObjs1 = oModelDoc.AttributeManager.FindObjects("*", "*", "Rolle_Top")
Edge1 = oObjs1.Item(1)
Catch
End Try
Try
'Find Face 2 on the model
Dim oObjs2 As ObjectCollection
oObjs2 = oModelDoc.AttributeManager.FindObjects("*", "*", "Fuss_Bot")
Edge2 = oObjs2.Item(1)
Catch
End Try
Next
Dim oLeafOccs As ComponentOccurrencesEnumerator
oLeafOccs = oAssembly.ComponentDefinition.Occurrences.AllLeafOccurrences
' Iterate through the occurrences and print the name.
Dim oOcc As ComponentOccurrence
For Each oOcc In oLeafOccs
If oOccEdge1Proxy Is Nothing Then
Try
Call oOcc.CreateGeometryProxy(Edge1, oOccEdge1Proxy)
Catch
End Try
End If
If oOccEdge2Proxy Is Nothing Then
Try
Call oOcc.CreateGeometryProxy(Edge2, oOccEdge2Proxy)
Catch
End Try
End If
Next
Try
Dim aoDrawCurves1 As DrawingCurve
oDrawViewCurves = oView.DrawingCurves(oOccEdge1Proxy)
aoDrawingCurves1 = oDrawViewCurves.Item(1)
Dim aoDrawCurves2 As DrawingCurve
oDrawViewCurves = oView.DrawingCurves(oOccEdge2Proxy)
aoDrawingCurves2 = oDrawViewCurves.Item(1)
Dim GI1 As GeometryIntent
GI1 = oSheet.CreateGeometryIntent(aoDrawingCurves1)
Dim GI2 As GeometryIntent
GI2 = oSheet.CreateGeometryIntent(aoDrawingCurves2)
Dim TextPoint As Point2d
Dim XPos As Double
Dim YPos As Double
XPos = oView.Left - 0.5
YPos = oView.Top - (oView.Height / 2)
TextPoint = ThisApplication.TransientGeometry.CreatePoint2d(XPos, YPos)
Dim oDim1 As GeneralDimension
oDim1 = oGeneralDims.AddLinear(TextPoint, GI1, GI2)
Catch
End Try
Does anyone know what I am doing wrong?
Thanks for your help!