Creating ordinated Drawing using iLogic

Creating ordinated Drawing using iLogic

joe_love-gunn
Contributor Contributor
218 Views
2 Replies
Message 1 of 3

Creating ordinated Drawing using iLogic

joe_love-gunn
Contributor
Contributor

Hi, I am currently in the process of creating a iLogic tool which will automatically ordinate all the cutout points on a part which automatically adds the cutouts to a templated iLogic flooring panel. In order to do this I am taking a workpoint within the drawing which adapts to the max width of the flooring plan depending on the layout design. This workpoint is called "Corner 3" and I intend to use this point on the view as the origin point for the drawing ordinate measurements when coming to fabrication drawings.

 

I am fairly new to iLogic and from the API the syntax to create the origin indicator for the view is:

DrawingView.CreateOriginIndicator(Intent as Geometry intent). and from what I read a workpoint/centremark would class as a valid geometry intent. However when I run my code no origin indicator is created. I believe I misunderstood the geometry intent function. I understand that the x and y coordinates I have outputted from the workpoint are transient geometry, However I am unsure where to look or how I would go about setting those points as a geometry intent to set the Origin point, Any information on Geometry Intent and creation of ordinates within iLogic would be of great help.

0 Likes
219 Views
2 Replies
Replies (2)
Message 2 of 3

joe_love-gunn
Contributor
Contributor

Update - I have managed to place the Origin point now and it fixes to the correct location, and I have continued to now add ordinates to the view, It will iterate through each line on the form sketch of the part creating an ordinate dimension at the start and end point of each line in its respected direction, dependant on the line/curve orientation. However when I attempt to define the geometry Intent "oDimIntent1" and "oDimIntent2" it fails to define the intent and exits the code (between the debug message boxes "Test1" and "Test2", I believe it is due to me calling my sketch Line SkLine and it not being an entity name but the entity itself, see code below.

 

Sub Main()
If TypeOf ThisDoc.Document Is DrawingDocument Then
	
	Dim drw As DrawingDocument = ThisDoc.Document
	Dim activeSheet As Sheet = drw.ActiveSheet

	For Each drwView As DrawingView In activeSheet.DrawingViews
		Try
			oSheet = ThisDrawing.ActiveSheet
			If IsNothing(drwView) Then
				Exit Sub
			End If

			'Set Model View to standard - Unshaded - Hidden Line Removed
			drwView.ViewStyle = kHiddenLineRemovedDrawingViewStyle
			
			'Get Model Form Sketch
			Dim oDrawingDoc As DrawingDocument
			oDrawingDoc = ThisDoc.Document
			
			Dim oPart As Document
			oPart = drwView.ReferencedDocumentDescriptor.ReferencedDocument
			
			Dim oPartDef As PartComponentDefinition
			oPartDef = oPart.ComponentDefinition
			
			Dim oSketch As PlanarSketch
			
			'Include Formsketch on drawing View
			Dim oFormSketch As PlanarSketch = oPartDef.Sketches.Item("Form Sketch")
			drwView.SetIncludeStatus(oFormSketch, True)
			drwView.SetVisibility(oFormSketch, True)
			
			'Set View to Pull Intents from model for ordination
			oViewName = drwView.Name
			oView = ThisDrawing.ActiveSheet.View(oViewName)
			
			'Create Origin Indicator if one does not exist
			If drwView.HasOriginIndicator = False Then
				
				'Run Create Ordinate Origin Indicator Subroutine
				Create_Origin_Indicator(oView, drwView)

			End If

		'Add Ordinate Dims
			Try
			'Create a X-Axis Vector to check for Horizontal Lines
			Dim oXAxis As Vector2d
			oXAxis = ThisApplication.TransientGeometry.CreateVector2d(1, 0)

			'Create a Y-Axis Vector to check for Vertical Lines
			Dim oYAxis As Vector2d
			oYAxis = ThisApplication.TransientGeometry.CreateVector2d(0, 1)
			
			'Create Text Origin For Text placement of Ord Dim
			Dim oTextOrigin1 As Point2d
			Dim oTextOrigin2 As Point2d

			'Dim Type Variable For Horizontal or Vertical Dependant on Line Direction
			Dim DimType As DimensionTypeEnum

			'Iterate all sketch entity to check for Lines
			For Each SkLine As SketchLine In oFormSketch.SketchLines
				Dim StartPoint As Point2d = SkLine.StartSketchPoint.Geometry
				Dim EndPoint As Point2d = SkLine.EndSketchPoint.Geometry
								
				'Create Curve Vectors for Line to check if parallel
				Dim oCurveVector As Vector2d
				oCurveVector = StartPoint.VectorTo(EndPoint)
				
				If oCurveVector.IsParallelTo(oXAxis) Then
								MsgBox("Test")	
					'Set Dim Direction
					DimType = DimensionTypeEnum.kVerticalDimensionType
									MsgBox("Test 1")
					Dim oDimIntent1 As GeometryIntent = oView.GetIntent(SkLine, PointIntentEnum.kStartPointIntent)
					Dim oDimIntent2 As GeometryIntent = oView.GetIntent(SkLine, PointIntentEnum.kEndPointIntent)
									MsgBox("Test 2")	
					'Set the Text Points for the 2 Dimensions
					oTextOrigin1 = ThisApplication.TransientGeometry.CreatePoint2d(SkLine.StartSketchPoint.X, oView.Top + 5)
					oTextOrigin2 = ThisApplication.TransientGeometry.CreatePoint2d(SkLine.EndSketchPoint.X, oView.Top + 5)
					
					'Create First Ordinate Dimension
					drwView.OrdinateDimensions.Add(oDimIntent1, oTextOrigin1, DimType)
					'Create Second Ordinate Dimension
					drwView.OrdinateDimensions.Add(oDimIntent2, oTextOrigin2, DimType)
					
					MsgBox("Parallel to X")
					
				Else If oCurveVector.IsParallelTo(oYAxis) Then
					
					'Set Dim Direction
					DimType = kHorizontalDimensionType
								MsgBox("Test3")	
					'Set Dim Direction
					DimType = kVerticalDimensionType
									MsgBox("Test 4")
					Dim oDimIntent1 As GeometryIntent = oView.GetIntent(SkLine, kStartPointIntent)
					Dim oDimIntent2 As GeometryIntent = oView.GetIntent(SkLine, kEndPointIntent)
									MsgBox("Test 5")	
					'Set the Text Points for the 2 Dimensions
					oTextOrigin1 = ThisApplication.TransientGeometry.CreatePoint2d(SkLine.StartSketchPoint.X, oView.Top + 5)
					oTextOrigin2 = ThisApplication.TransientGeometry.CreatePoint2d(SkLine.EndSketchPoint.X, oView.Top + 5)
					
					'Create First Ordinate Dimension
					drwView.OrdinateDimensions.Add(oDimIntent1, oTextOrigin1, DimType)
					'Create Second Ordinate Dimension
					drwView.OrdinateDimensions.Add(oDimIntent2, oTextOrigin2, DimType)
					MsgBox("Parallel to Y")
					
				Else
					MsgBox("Parallel to none")
					
				End If				
				
				'Debug Coords
				' Format the start point coordinates as a string
'			    Dim startPointString As String = "Start Point: (" & StartPoint.X.ToString() & ", " & StartPoint.Y.ToString() & ")"
			
'			    ' Format the end point coordinates as a string
'			    Dim endPointString As String = "End Point: (" & EndPoint.X.ToString() & ", " & EndPoint.Y.ToString() & ")"
'			    ' Display the start point in a message box
'			    MsgBox(startPointString)
			
'			    ' Display the end point in a message box
'			    MsgBox(endPointString)

			Next
			
			Catch
				
			End Try
			
		Catch

		End Try
		
		Next
		
End If
End Sub
	
'Set Ordinate Origin Subroutine
Sub Create_Origin_Indicator(oView, drwView)
	
	'Set Intent for ordinate origin
	Dim Ord_Origin_Intent As GeometryIntent = oView.GetIntent("Corner 3")

	'Create Ordinate Origin
	drwView.CreateOriginIndicator(Ord_Origin_Intent)
	
End Sub

 I ran an excerpt of the code with a try seen below with the exit message of "operation is not valid due to the current state of the object"

0 Likes
Message 3 of 3

joe_love-gunn
Contributor
Contributor

If oCurveVector.IsParallelTo(oXAxis) Then
MsgBox("Test")

' Set Dim Direction
DimType = DimensionTypeEnum.kVerticalDimensionType
MsgBox("Test 1")

Try
Dim oDimIntent1 As GeometryIntent = oView.GetIntent(SkLine, PointIntentEnum.kStartPointIntent)
Dim oDimIntent2 As GeometryIntent = oView.GetIntent(SkLine, PointIntentEnum.kEndPointIntent)
MsgBox("Test 2")

' Set the Text Points for the 2 Dimensions
oTextOrigin1 = ThisApplication.TransientGeometry.CreatePoint2d(SkLine.StartSketchPoint.X, oView.Top + 5)
oTextOrigin2 = ThisApplication.TransientGeometry.CreatePoint2d(SkLine.EndSketchPoint.X, oView.Top + 5)

' Create First Ordinate Dimension
drwView.OrdinateDimensions.Add(oDimIntent1, oTextOrigin1, DimType)
' Create Second Ordinate Dimension
drwView.OrdinateDimensions.Add(oDimIntent2, oTextOrigin2, DimType)

MsgBox("Parallel to X")
Catch ex As Exception
MsgBox("Error creating GeometryIntents: " & ex.Message)
End Try

0 Likes