Jump to content

How to convert trace to line or polyline


batman67

Recommended Posts

I have 200 plans drawn by the command of trace. I want to convert the trace line to simple line. I have made a macro to convert the trace line to polyline. But the result is that it is not a staright line. Anyone can help me to solve this problem. Thanks

Link to comment
Share on other sites

Try this code

(DEFUN C:TEST (/ SS I TEMP)
 (SETQ	SS (SSGET '((0 . "TRACE")))
I  -1
 )
 (REPEAT (SSLENGTH SS)
   (SETQ TEMP (ENTGET (SSNAME SS (SETQ I (1+ I))))
   )
   (ENTMAKE
     (LIST
'(0 . "LINE")
(ASSOC 8 TEMP)
(IF (ASSOC 62 TEMP)
  (ASSOC 62 TEMP)
  '(62 . 256)
)
(CONS 10
      (MAPCAR '(LAMBDA (X Y) (/ (+ X Y) 2))
	      (CDR (ASSOC 10 TEMP))
	      (CDR (ASSOC 11 TEMP))
      )
)
(CONS 11
      (MAPCAR '(LAMBDA (X Y) (/ (+ X Y) 2))
	      (CDR (ASSOC 12 TEMP))
	      (CDR (ASSOC 13 TEMP))
      )
)
(ASSOC 210 TEMP)
     )
   )
   (ENTDEL (SSNAME SS I))
 )
)

Link to comment
Share on other sites

Sub CommandButton1_Click()

Dim entry As AcadObject

Dim MyLine As AcadLine

Dim MyTrace As AcadTrace

Dim MyPoly As AcadPolyline

Dim MyThick As Double

Dim MyLineType As ACAD_LTYPE

Dim MyPoints(0 To 5) As Double

Dim CordPoints

If TextBox1.Text > vbNullString Then

MyThick = TextBox1.Text

Else

MyThick = 0.003 '

End If

For Each entry In ThisDrawing.ModelSpace

'MsgBox entry.ObjectName

If TypeOf entry Is AcadLine Then

Set MyLine = entry

MyLineType = MyLine.Linetype

MyPoints(0) = MyLine.EndPoint(0)

MyPoints(1) = MyLine.EndPoint(1)

MyPoints(2) = 0

MyPoints(3) = MyLine.StartPoint(0)

MyPoints(4) = MyLine.StartPoint(1)

MyPoints(5) = 0

Set MyPoly = ThisDrawing.ModelSpace.AddPolyline(MyPoints)

MyPoly.ConstantWidth = MyThick

MyPoly.Linetype = MyLineType

MyPoly.Update

MyLine.Delete

'Set MyLine = Nothing

'Set MyPoly = Nothing

ElseIf TypeOf entry Is AcadTrace Then

Set MyTrace = entry

CordPoints = MyTrace.Coordinate(0)

MyPoints(0) = CordPoints(0)

MyPoints(1) = CordPoints(1)

MyPoints(2) = CordPoints(2)

CordPoints = MyTrace.Coordinate(3)

MyPoints(3) = CordPoints(0)

MyPoints(4) = CordPoints(1)

MyPoints(5) = CordPoints(2)

Set MyPoly = ThisDrawing.ModelSpace.AddPolyline(MyPoints)

MyPoly.ConstantWidth = MyThick

MyPoly.Update

MyTrace.Delete

'Set MyTrace = Nothing

'Set MyPoly = Nothing

End If

Next entry

Set entry = Nothing

Set MyTrace = Nothing

Set MyPoly = Nothing

Set MyLine = Nothing

Unload Me

End Sub

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...