Message 1 of 17
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I got the following code, it runs but it doesn't place a annotation,
I have adjusted quite a few things but can't figure out what i'm doing wrong, i think it's something small and is to be found in the first half of the code.....
more info: my sheetname in the dwg is 'MAIN'
Public Sub WorkPoints
Dim oDrawingDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oStyle As DrawingStylesManager = oDrawingDoc.StylesManager
Dim oAssyDoc As AssemblyDocument = oDrawingDoc.AllReferencedDocuments.Item(1)
Dim oAssyCompDef As AssemblyComponentDefinition = oAssyDoc.ComponentDefinitions.Item(1)
Dim oCMStyle As CentermarkStyle = oStyle.CentermarkStyles.Item("Center Mark (ANSI)")
'*Define workpoint arrays
Dim sDimPt(2, 1) As String
Dim Pt1 As Integer = 0
'*Define annotation start point
sDimPt(0, Pt1) = "PS1"
'*Define annotation end points
sDimPt(0, Pt2) = "PE1"
'*Define the views on which the annotation should be placed
sDimPt(0, Pt3) = "View2"
'*Define sheet on which annotation should be placed
sDimPt(0, Pt4) = "1"
'*Define annotation orientation
sDimPt(0, Pt5) = "Horizontal"
'*Loop array to place
For j = 0 To 1
sDimPt1 = sDimPt(j, Pt1)
sDimPt2 = sDimPt(j, Pt2)
viewName = sDimPt(j, Pt3)
sheetIndex = CInt(sDimPt(j, Pt4))
ActiveSheet = ThisDrawing.Sheet("MAIN:" & sheetIndex)
Dim oView As DrawingView = ActiveSheet.View(viewName).View
Dim oSheet As Sheet = oDrawingDoc.Sheets.Item(sheetIndex)
CreateLinearDimension(oAssyCompDef, oView, oDrawingDoc, oSheet, sDimPt1, sDimPt2, oCMStyle, oDimType)
Next j
End Sub
'*iLogic automation annotation placement//////////////////////////////////////////////////////////////////////
Private Sub CreateLinearDimension(ByVal oAssyCompDef As AssemblyComponentDefinition, oView As DrawingView, oDrawingDoc As DrawingDocument, oSheet As Sheet, sDimPt1 As String, sDimPt2 As String, oCMStyle As CentermarkStyle, oDimType As String)
Dim oTG As TransientGeometry
oTG = ThisApplication.TransientGeometry
'---------Get Assembly Workpoints as Sheetpoints---------
oWP1 = oAssyCompDef.WorkPoints.Item(sDimPt1)
oWP2 = oAssyCompDef.WorkPoints.Item(sDimPt2)
'---------Declare variables for Dimeensions endpoints and text location---------
Dim oSheetPt1 As Point2d
Dim oSheetPt2 As Point2d
Dim oPtText As Point2d
'---------Add Centermarks on the drawing attached to the assemblu workpoints for geometry intent---------
Dim oCenterMark1 As Centermark
Dim oCenterMark2 As Centermark
'---------Create Geometry intent---------
Dim oGeomIntent1 As GeometryIntent
Dim oGeomIntent2 As GeometryIntent
oGeomIntent1 = oSheet.CreateGeometryIntent(oCenterMark1, oSheetPoint1)
oGeomIntent2 = oSheet.CreateGeometryIntent(oCenterMark2, oSheetPoint2)
'---------Define Dimension Text Location---------
Dim oPlaceDimX As Double
Dim oPlaceDimY As Double
If oDimType = "Vertical" Then
oPlaceDimX = oSheetPt1.X
oPlaceDimY = oSheetPt1.Y
dimTypeVal = 60163
Else If oDimType = "Horizontal" Then
oPlaceDimX = oSheetPt1.X
oPlaceDimY = oSheetPt1.Y
dimTypeVal = 60162
End If
oPtText = oTG.CreatePoint2d(oPlaceDimX, oPlaceDimY0)
'---------Create Dimension And center the text between the leaders---------
Dim oDimension As DrawingDimension
oDimension = oSheet.DrawingDimensions.GeneralDimensions.AddLinear(oPtText, oGeomIntent1, oGeomIntent2, dimTypeVal)
End Sub
Solved! Go to Solution.