I'm not completely sure what you want the end result to look like. (I guessed that the image shows the sketch not the end result.) But I think that this rule will do more or less what you want and I hope it's easy enough to change it.
Public Sub main
Dim view As DrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select a View")
Dim sketch As DrawingSketch = view.Sketches.Add()
Dim cp = sketch.SheetToSketchSpace(view.Position)
Dim blue As Color = ThisApplication.TransientObjects.CreateColor(0, 0, 255)
Dim offSetFromView As Double = 1
sketch.Edit()
Dim lines = CreateRectangle(sketch, cp, view.Width + offSetFromView, view.Height + offSetFromView)
SetLayer(lines, LineTypeEnum.kDashedLineType, 0.05, blue)
sketch.ExitEdit()
End Sub
Public Sub SetLayer(lines As SketchEntitiesEnumerator, LineType As LineTypeEnum, LineWeight As Double, color As Color)
For Each line As SketchEntity In lines
Line.Layer.LineType = LineTypeEnum.kDashedLineType
Line.Layer.LineWeight = LineWeight
Line.Layer.Color = color
Next
End Sub
Public Function CreateRectangle(Sketch As DrawingSketch, cp As Point2d, w As Double, h As Double) As SketchEntitiesEnumerator
Dim oTg = ThisApplication.TransientGeometry
Dim p1 As Point2d = cp.Copy()
p1.TranslateBy(oTg.CreateVector2d(w / 2, h / 2))
Dim p3 = p1.Copy()
p3.TranslateBy(oTg.CreateVector2d(-w, -h))
Dim lines = Sketch.SketchLines.AddAsTwoPointRectangle(p1, p3)
Return lines
End Function
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.

Blog: hjalte.nl - github.com