batman67 Posted April 4, 2010 Share Posted April 4, 2010 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 Quote Link to comment Share on other sites More sharing options...
ReMark Posted April 4, 2010 Share Posted April 4, 2010 Why did you convert to a polyline then instead of an ordinary line? Quote Link to comment Share on other sites More sharing options...
BearDyugin Posted April 4, 2010 Share Posted April 4, 2010 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)) ) ) Quote Link to comment Share on other sites More sharing options...
batman67 Posted April 5, 2010 Author Share Posted April 5, 2010 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 Quote Link to comment Share on other sites More sharing options...
batman67 Posted April 5, 2010 Author Share Posted April 5, 2010 I am sorry. I do not know how to use the code. Can you give me instruction. Thanks Quote Link to comment Share on other sites More sharing options...
Cad64 Posted April 5, 2010 Share Posted April 5, 2010 How to use an AutoLisp Routine: http://www.cadtutor.net/faq/questions/28/How+do+I+use+an+AutoLISP+routine%3F Quote Link to comment Share on other sites More sharing options...
batman67 Posted April 5, 2010 Author Share Posted April 5, 2010 I have done it very well. Thank you! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.