TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: CAB on November 19, 2003, 05:19:27 PM
-
Maybe someone has an easy solution.
This routine has the user draw an arc and then places a 4" circle at
the first point picked. My problem is in trimming the arc that is
within the circle. If i use ptPick instead of ArcEnt sometimes the
arc was started on top of another entity and it ia trimmed instead.
But using ArcEnt has it's own problems. If the Arc is drawn in a
particular direction the part outside of the circle is trimmed.
Any easy fix for this? :oops:
CAB
;;; By Charles Alan Butler : Last Modified 11/19/03
;;; ArcC.lsp (Arc Leader with Circle Arrow Head)
;;; Uses the current layer & Circle Arrow head
;; error function & Routine Exit
(defun *error* (msg)
(if
(not
(member
msg
'("console break" "Function cancelled" "quit / exit abort")
)
)
(princ (strcat "\nError: " msg))
) ; if
(princ)
) ;
;end error function
;;;====== Main Lisp Routine =======
(defun c:ArcC (/ usercmd useros pt1 pt2
pttemp ptpick L_Angle cenpt rad
StartAng arcdata EndAng
)
(princ "\n")
(princ "\n Arc Leader w/ Circle Arrow - Version 1.0")
(princ "\n")
;;; ------- Some Housekeeping ------------------
(setq usercmd (getvar "CMDECHO"))
(setvar "CMDECHO" 0)
(setq useros (getvar "osmode"))
(setvar "osmode" 0)
(setq userANGDIR (getvar "angdir"))
(setvar "angdir" 0)
(setq ptpick (getpoint "\nPick leader start point: "))
(command "arc" ptpick pause pause)
(if (= "ARC" (cdr (assoc 0 (entget (entlast)))))
(progn
(setq ArcEnt (entlast))
(setq arcdata (entget ArcEnt)
cenpt (cdr (assoc 10 arcdata))
rad (cdr (assoc 40 arcdata))
StartAng (cdr (assoc 50 arcdata))
EndAng (cdr (assoc 51 arcdata))
)
(Command "_.Circle" ptpick 2) ; circle arrow head 2" radius
(ssget "l") ; use circle as cutting edge
(command "trim" "p" "" ArcEnt "") ; trim arc only
;;;========== Exit Sequence ============
(setvar "osmode" useros)
(setvar "CMDECHO" usercmd)
(setvar "angdir" userangdir)
(princ)
) ; end progn
) ; endif ARC
) ; end defun
(prompt "\nType ArcC to run")
(princ)
;;;========== End of Routine ============
-
Set your osnap to none (setvar "osmode" 0)
Save the arc entity name preserving the endpoint
inside the circle. (setq ArcEnt (list (entlast) ptpick))
Trim the end of the arc after circle command:
(command "_trim" (entlast) "" ArcEnt "")
Try these changes and your routine will work
flawlessly (hopefully...)
-
THANKS, it worked, but why? :(
How does this line work?
(command "_trim" (entlast) "" ArcEnt "")
I know the (entlast) picks the circle but how does
ArcEnt work? it is
(<Entity name: 1b8b5d8> (110.363 92.1785 0.0))
I must have slept through that class :shock:
Here is the revised routine
;;; By Charles Alan Butler : Last Modified 11/19/03
;;; ArcC.lsp (Arc Leader with Circle Arrow Head)
;;; Uses the current layer & Circle Arrow head
;; error function & Routine Exit
(defun *error* (msg)
(if
(not
(member
msg
'("console break" "Function cancelled" "quit / exit abort")
)
)
(princ (strcat "\nError: " msg))
) ; if
(princ)
) ;
;end error function
;;;====== Main Lisp Routine =======
(defun c:ArcC (/ usercmd useros pt1 pt2
pttemp ptpick L_Angle cenpt rad
StartAng arcdata EndAng
)
(princ "\n")
(princ "\n Arc Leader w/ Circle Arrow - Version 1.0")
(princ "\n")
;;; ------- Some Housekeeping ------------------
(setq usercmd (getvar "CMDECHO"))
(setvar "CMDECHO" 0)
(setq useros (getvar "osmode"))
(setvar "osmode" 0)
(setq userANGDIR (getvar "angdir"))
(setvar "angdir" 0)
(setq ptpick (getpoint "\nPick leader start point: "))
(command "arc" ptpick pause pause)
(if (= "ARC" (cdr (assoc 0 (entget (entlast)))))
(progn
(setq ArcEnt (list (entlast) ptpick))
(setq arcdata (entget (entlast))
cenpt (cdr (assoc 10 arcdata))
rad (cdr (assoc 40 arcdata))
StartAng (cdr (assoc 50 arcdata))
EndAng (cdr (assoc 51 arcdata))
)
(Command "_.Circle" ptpick 2) ; circle arrow head 2" radius
(command "_trim" (entlast) "" ArcEnt "")
;;;========== Exit Sequence ============
(setvar "osmode" useros)
(setvar "CMDECHO" usercmd)
(setvar "angdir" userangdir)
(princ)
) ; end progn
) ; endif ARC
) ; end defun
(prompt "\nType ArcC to run")
(princ)
;;;========== End of Routine ============
-
ArcEnt always is the arc endpoint inside the
circle. Try compare the center of the circle to
the entity list of the arc ename (ArcEnt). The
2 points are always identical.
-
I guess my question is how does adding the center point onto the entity name work? I've never seen that before
(setq ArcEnt (entlast))
versus this
(setq ArcEnt (list (entlast) ptpick))
it's just that I want understand it so i'm able to use it again.
Is it a selection method that lets you pick an entity at a certin point as if you picked it
with the cursor?
This is really neat. :D
Thanks
CAB
-
<<it's just that I want understand it so i'm able to use it again.
<<Is it a selection method that lets you pick an entity at a certin
<< point as if you picked it with the cursor?
Yes, the code is the equivalent of (entsel) without
user intervention (no picking of object). This trick is
aka Version R9/R10.
-
<<<Yes, the code is the equivalent of (entsel) without
<<<user intervention (no picking of object). This trick is
<<<aka Version R9/R10.
Definitely missed that Class, I just started Acad with 2000.
Can't wait to use it again. :)
CAB