Message 1 of 7
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi everyone
I am new to the API, and I would like to add a dimension to a view based on prenamed edges ( one called Left and the other Called Right) in the model which is simply an extruded rectangular.
the error occurred during debugging at the last line of the code and I have tried to figure out its causes without finding a solution.
Here is my code
Sub CreateDimensionModel() 'Reference the file that's open Dim oDrawDoc As DrawingDocument Set oDrawDoc = ThisApplication.ActiveDocument 'Reference the active Sheet Dim oSheet As Sheet Set oSheet = oDrawDoc.ActiveSheet 'Reference the View we want Dim oView As DrawingView Set oView = oSheet.DrawingViews.Item(1) 'Reference the Model on that Sheet Dim oModelDoc As Document Set oModelDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument ' Create a shortcut to the General dimensions on the sheet Dim oGeneralDims As GeneralDimensions Set oGeneralDims = oSheet.DrawingDimensions.GeneralDimensions 'Find edge 1 (Left) on the Model Dim Edge1 As Edge Set oObjs = oModelDoc.AttributeManager.FindObjects("*", "*", "Left") Set Edge1 = oObjs.Item(1) 'Find edge 1 (Right) on the Model Dim Edge2 As Edge Set oObjs = oModelDoc.AttributeManager.FindObjects("*", "*", "Right") Set Edge2 = oObjs.Item(1) 'Promote to an DrawingCurve on the View Dim OCurves1 As DrawingCurve Set OViewCurves1 = oView.DrawingCurves(Edge1) Set OCurves1 = OViewCurves1.Item(1) Dim OCurves2 As DrawingCurve Set OViewCurves2 = oView.DrawingCurves(Edge2) Set OCurves2 = OViewCurves1.Item(1) 'Promote to a geometryintent onthe sheet Dim GI1 As GeometryIntent Set GI1 = oSheet.CreateGeometryIntent(OCurves1) Dim GI2 As GeometryIntent Set GI2 = oSheet.CreateGeometryIntent(OCurves2) 'Create a point for the text Dim Textpoint As Point2d Dim Xpos As Double Dim Ypos As Double Xpos = oView.Left + (oView.Width / 2) Ypos = oView.Top + 3 Set Textpoint = ThisApplication.TransientGeometry.CreatePoint2d(Xpos, Ypos) 'Create the Dimension Dim oDim1 As GeneralDimension Set oDim1 = oGeneralDims.AddLinear(Textpoint, GI1, GI2) End Sub
Thanks for help
Solved! Go to Solution.