;;; Created for: http://www.bricsys.com/common/support/forumthread.jsp?id=26089
;;; Author: Roy Klein Gebbinck (www.b-k-g.nl)
;;; Modified: Marko Ribar (AutoCAD implementation)
(defun c:ArcFollow ( / cmde deriv dist lst obj pt el)
(vl-load-com)
(if
(and
(setq lst (entsel))
(setq obj (vlax-ename->vla-object (car lst)))
(or
(vl-position
(vla-get-objectname obj)
'("AcDb2dPolyline" "AcDbArc" "AcDbCircle" "AcDbEllipse" "AcDbLine" "AcDbPolyline" "AcDbSpline")
)
(prompt "\nError: invalid object \n")
)
(or
(equal (vlax-get obj 'normal) (trans '(0.0 0.0 1.0) 1 0 T) 1e-8)
(prompt "\nError: object not co-planar with current UCS \n")
)
)
(progn
(setq dist (vlax-curve-getdistatpoint obj (vlax-curve-getclosestpointto obj (trans (cadr lst) 1 0))))
(if (< dist (- (vlax-curve-getdistatparam obj (vlax-curve-getendparam obj)) dist))
(progn ; Closer to the start point.
(setq pt (vlax-curve-getstartpoint obj))
(setq deriv (mapcar '- (vlax-curve-getfirstderiv obj (vlax-curve-getstartparam obj))))
)
(progn
(setq pt (vlax-curve-getendpoint obj))
(setq deriv (vlax-curve-getfirstderiv obj (vlax-curve-getendparam obj)))
)
)
(setq cmde (getvar 'cmdecho))
(setvar 'cmdecho 0)
(setq el (entlast))
(vl-cmdf "_.LINE" "_non" (trans pt 0 1) "_non" (trans (mapcar '- pt deriv) 0 1) "_non" (trans pt 0 1) "")
(while (setq el (entnext el))
(entdel el)
)
(vl-cmdf
"_.arc"
""
)
(while (> (getvar 'cmdactive) 0)
(vl-cmdf "\\")
)
(setvar 'cmdecho cmde)
)
)
(princ)
)
@ribarm:
Thanks.
So using the Direction option, which is available in AutoCAD as well, is not feasible in that program?
Command: arcfollow
Select object:
2D point or option keyword required.
; error: Function cancelled
Specify second point of arc or [Center/End]:
Specify end point of arc:
Command: *Cancel*
@ribarm:
You have misunderstood my previous post. If you step back to my code you will see that it uses the Direction option of the Arc command. According to the docs this option is also available in AutoCAD. What are your reasons for changing this part of the code?
The Direction Option of the ARC command in AutoCAD ... It's not the same as BricsCAD.Thanks for clarifying.
(while (setq el (entnext el))
(entdel el)
)
To this:(if (not (equal el (entlast)))
(entdel (entlast))
)
Reason: entnext will also catch sub-entities.
The Direction Option of the ARC command in AutoCAD ... It's not the same as BricsCAD.Thanks for clarifying.
I would change this in ribarm's code:Code: [Select](while (setq el (entnext el))
To this:
(entdel el)
)Code: [Select](if (not (equal el (entlast)))
Reason: entnext will also catch sub-entities.
(entdel (entlast))
)