Message 1 of 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Good morning,
My other post got a bit lengthy, managed to isolate the problem, haven't found a solution yet.
See the added files, im wondering wether it works for other people
When running the rule in the dwg, i get the following error:
Code for reference:
'Drawing Document
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
MsgBox("This rule '" & iLogicVb.RuleName & "' only works for Drawing Documents.",vbOKOnly, "WRONG DOCUMENT TYPE")
Return
End If
Dim oDDoc As DrawingDocument = ThisDrawing.Document
If oDDoc Is Nothing Then MsgBox("No Active Drawing Document Found. Exiting.") : Return
'Model Document
If ThisDrawing.ModelDocument Is Nothing Then
MsgBox("There is no model document associated with this drawing. Exiting.", vbOKOnly + vbExclamation, " ")
Return
End If
Dim oMDocType As DocumentTypeEnum = ThisDrawing.ModelDocument.DocumentType
Dim oADoc As AssemblyDocument
Dim oADef As AssemblyComponentDefinition
If oMDocType = DocumentTypeEnum.kAssemblyDocumentObject Then
oADoc = ThisDrawing.ModelDocument
oADef = oADoc.ComponentDefinition
Else
MsgBox("The main model file being reference by this drawing is not an assembly." & vbCrLf & _
"This rule only works when the model is an assembly document. Exiting.", vbOKOnly + vbExclamation, " ")
Return
End If
Dim oSheet As Sheet = oDDoc.Sheets.Item(1)
Dim oView As DrawingView
For Each oDView As DrawingView In oSheet.DrawingViews
If oDView.Name.Contains("VIEW2") Then
oView = oDView
End If
Next
If oView Is Nothing Then
MsgBox("Couln't find a sheet with 'View2' in its name. Exiting.", vbOKOnly + vbExclamation, "VIEW NOT FOUND")
Return
End If
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim oWP1 As WorkPoint
Dim oWP2 As WorkPoint
Try
oWP1 = oADef.WorkPoints.Item("PS1")
oWP2 = oADef.WorkPoints.Item("PE1")
Catch oEx As Exception
MsgBox("Couldn't find WorkPoints named 'PS1' & 'PE1'. Exiting.")
Return
End Try
Dim oStyleMgr As DrawingStylesManager = oDDoc.StylesManager
Dim oCMStyle As CentermarkStyle
Try
oCMStyle = oStyleMgr.CentermarkStyles.Item("Center Mark (ANSI)")
Catch oEx As Exception
oProceed = MsgBox("Coundn't find a CentermarkStyle named 'Center Mark (ANSI)'." & vbCrLf & _
"Do you want to proceed without specifying the Style?", vbYesNo + vbQuestion, "STYLE NOT FOUND")
If oProceed = vbNo Then Return
End Try
Dim oCP1 As Centermark = oSheet.Centermarks.AddByWorkFeature(oWP1, oView, oCMStyle)
Dim oCP2 As Centermark = oSheet.Centermarks.AddByWorkFeature(oWP2, oView, oCMStyle)
Dim oInt1 As GeometryIntent = oSheet.CreateGeometryIntent(oCP1)
Dim oInt2 As GeometryIntent = oSheet.CreateGeometryIntent(oCP2)
Dim oPtText As Point2d
Dim oDimType As DimensionTypeEnum
Dim oHorV As String = "Horizontal" 'or "Vertical"
If oHorV = "Horizontal" Then
oDimType = DimensionTypeEnum.kHorizontalDimensionType
oPtText = oTG.CreatePoint2d(oView.Center.X,(oView.Top + 1))
Else
oDimType = DimensionTypeEnum.kVerticalDimensionType
oPtText = oTG.CreatePoint2d((oView.Left-1),oView.Center.Y)
End If
Dim oDim As DrawingDimension
Try
oDim = oSheet.DrawingDimensions.GeneralDimensions.AddLinear(oPtText, oGeomIntent1, oGeomIntent2, oDimType)
Catch oEx As Exception
MsgBox("The attempt to create the dimension failed." & vbCrLf & _
"The Error message is as follows:" & vbCrLf & _
oEx.Message & vbCrLf & vbCrLf & _
"The Source is as follows:" & vbCrLf & _
oEx.Source, vbOKOnly + vbExclamation, " ")
End Try
Solved! Go to Solution.