Create line on drawing

Create line on drawing

michielXWZ7U
Enthusiast Enthusiast
206 Views
2 Replies
Message 1 of 3

Create line on drawing

michielXWZ7U
Enthusiast
Enthusiast

Hi,

I am looking for a solution to do the following:

On a drawing:

create a sketch

add a vertical line (coordinates does not matter)

Exit the sketch

If there is someone that knows how to arrange this, that would be amazing!

With kind regards,

Mich

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

WCrihfield
Mentor
Mentor

Hi @michielXWZ7U. Here is a simple example of an iLogic rule you could use to draw a vertical sketch line on a drawing.

If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
	MsgBox("A Drawing document must be active for this code to work. Exiting.", vbCritical, "")
	Exit Sub
End If
Dim oDDoc As DrawingDocument = ThisDoc.Document
Dim oSketch As DrawingSketch = oDDoc.ActiveSheet.Sketches.Add
oSketch.Edit
Dim oSLs As SketchLines = oSketch.SketchLines
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim oStartPoint As Point2d = oTG.CreatePoint2d(3, 3)
Dim oEndPoint As Point2d = oTG.CreatePoint2d(3, 6)
Dim oSL As SketchLine = oSLs.AddByTwoPoints(oStartPoint, oEndPoint)
oSketch.ExitEdit

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 3

Daan_M
Collaborator
Collaborator
Dim oDoc As DrawingDocument = ThisDoc.Document
Dim oSheet As Sheet = oDoc.Sheets.Item(1)
Dim oLine As SketchLine 

Dim oSketch As Sketch = oSheet.Sketches.Add()
oSketch.Edit
Dim oStartPoint As Point2d 	= ThisApplication.TransientGeometry.CreatePoint2d(1, 1)
Dim oEndPoint As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(10, 10)

oSketch.SketchLines.AddByTwoPoints(oStartPoint, oEndPoint)
0 Likes