Ilogic using workpoints to set dim.

Ilogic using workpoints to set dim.

Anonymous
Not applicable
574 Views
1 Reply
Message 1 of 2

Ilogic using workpoints to set dim.

Anonymous
Not applicable

So I'm trying to optimize our workflow on the standard components that we have at the company. Witch involves setting up some of the parts with a automatic drawing(with height, length etc.). I got the code down but I got 1 error that I just can figure out how to fix.

 

I have the error on linie 6, where the OStylesMgr is not being declared. I'm hoping that there just a typo or there a small ting I'm just not seeing. 

Sub Main
	Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
	Dim oStyle As DrawingStylesManager = oDoc.StylesManager
	Dim oAssyDoc As AssemblyDocument = oDoc.AllReferencedDocuments.Item(1)
	Dim oAssyCompDef As AssemblyComponentDefinition = oAssyDoc.ComponentDefinitions.Item(1)
	Dim oCMStyle As CentermarkStyle = oStylesMgr.CentermarkStyles.Item("Center Mark (ANSI)")
	
	'---------Defining workpoint Array---------
	Dim sDimPt(2, 5) As String
		Dim Pt1 As Integer = 0
		Dim Pt2 As Integer = 1
		Dim Pt3 As Integer = 2
		Dim Pt4 As Integer = 3
		Dim Pt5 As Integer = 4

	'---------Dimension Start point---------
	sDimPt(0, Pt1) = "DPHS"
	sDimPt(1, Pt1) = "DPHE"
	'sDimPt(2, Pt2) = "DPCS"
	'sDimPt(3, Pt2)=
	
	'---------Dimension End point---------
	sDimPt(0, Pt2) = "DPHE"
	sDimPt(1, Pt2) = "DPLE"
	'sDimPt(2, Pt2) = "DPCE"
	'sDimPt(2, Pt2)
	
	'---------Dimension View---------
	sDimPt(0, Pt3) = "VIEW1"
	sDimPt(1, Pt3) = "VIEW1"
	'sDimPt(2, Pt3) = "VIEW2"
	'sDimPt(3, Pt3) = "VIEW3"
	
	'---------Dimension Sheet---------
	sDimPt(0, Pt4) = "1"
	sDimPt(1, Pt4) = "1"
	'sDimPt(2, Pt4) = "1"
	'sDImPt(3, Pt4) = "2"
	
	'---------Dimension Orientation---------
	sDimPt(0, Pt5) = "Horizontal"
	sDimPt(0, Pt5) = "Vertical"
	'sDimPt(2, Pt5) = "" skal være et krydsmål
	
	'---------Loop thru Array placing dimensions---------
	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("VIEW1:" & sheetIndex)
				Dim oView As DrawingView = ActiveSheet.View(viewName).View
				Dim oSheet As Sheet = oDoc.Sheets.Item(sheetIndex)
					CreateLinearDimension(oAssyCompDef, oView, oDoc, oSheet, sDimPt1, sDimPt2, oCMStyle, oDimType)
				Next j
			End Sub
			
Private Sub CreateLinearDimension(ByVal oAssyCompDef As AssemblyComponentDefinition, oView As DrawingView, oDoc 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 - 2
			oPlaceDimY = oSheetPt1.Y
				dimTypeVal = 60163
			
			Else If oDimType = "Horizontal" Then
				oPlaceDimX = oSheetPt1.X
				oPlaceDimY = oSheetPt1.Y + 2
					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
		
				
		
575 Views
1 Reply
Reply (1)
Message 2 of 2

JelteDeJong
Mentor
Mentor

you declared the "oDoc.StylesManager" as "oStyle" but when you start using it you call for "oStylesMgr" i guess that is a typo.

ruletypo.png

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com