Eugene (archive)
Usenet Archive
- Joined
- Jan 27, 2001
- Messages
- 38
- Reaction score
- 0
Hello,
I thought I had this all figured out with lots of help from the NG (thanks). After further testing I see the problem isn't really fixed..... Here's the program; Draw a pline from point 1 to point 2, (points are user defined) Place a block w/ attribute at point 2 (The block is a note symbol, such as a circle, square, hex, or triangle) User to edit block attribute Trim the pline from intersecting the block symbol.
Please see the code below.......................
;;; CIRLEADER.LSP
;;;
;;; DESCRIPTION:
;;;
;;; This routine draws a leader line with a circle block note symbol ;;; ;;;ERROR HANDLING ROUTINE ;;;;;;;;;;;;;;;;;
(defun myerror (s) ; If an error (such as CTRL-C) occurs while this command is active... (if (/= s "Function cancelled") (princ (strcat "\nError: " s)) ) (setvar "cmdecho" icm) ; Restore saved modes (setvar "filedia" ifd) (setvar "cmddia" icd) (setvar "cecolor" "bylayer") (setq *error* olderr) ; Restore old *error* handler (princ)
)
;--MAIN PROGRAM------------------------------
(defun dtr (ang1) ;converts degrees to radians (because AutoCAD (* pi (/ ang1 180.0)) ;works in dergees & AutoLISP works in radians)
)
(defun ALE_LASTENT ( / ename result )
(and
(setq result (entlast))
(while (setq ename (entnext result)) (setq result ename)) ) result )
(defun ALE_SS-AFTER (ename / ss)
(cond
( (eq 'ename (type ename))
(setq ss (ssadd))
(while (setq ename (entnext ename))
(if (entget ename) (ssadd ename ss)))
(if (< 0 (sslength ss)) ss)
)
( T (alert "Attention: error in selection set (lastent)") )
) )
(defun c:cirleader (/ olderr ec as pa pm p1 p2 sz ad marker ) (setq olderr *error* *error* myerror) (setq ec (getvar "cmdecho")) (setvar "cmdecho" 0) (setq as (getvar "autosnap")) (setq pa (getvar "polarang")) (setq pm (getvar "polarmode")) (command "ucs" "view") (setvar "autosnap" 47) (setvar "polarang" 0.523598776) ;30 degrees (setvar "polarmode" 2) (setq p1 (getpoint "\nPick Leader Start...")) (setq p2 (getpoint p1 "\nPick Note Location...")) (setq sz (getvar "dimscale")) ;(command "ucs" "Previous") (setvar "autosnap" as) (setvar "polarang" pa) (setvar "polarmode" pm) (setvar "cmdecho" ec) (command "pline" p1 p2 nil) (setq ad (getvar "attdia")) (setvar "attdia" 1) (setq marker (ALE_LASTENT)) (command "-insert" "note-circle" p2 sz sz "0" ) (command "trim" (ALE_SS-AFTER marker) "" p2 nil ) (setvar "attdia" ad) (command "ucs" "Previous")
(princ)
)
I think the program is using the attribute for the trimming edge selection not the block....supporting reason; Trimmed pline is sporadic...sometimes it trims, sometimes it doesn't Seems to depend on the pline angle and attribute value if the pline is trimmed or not... Seems if the attribute value takes up more block real-estate (ie 00 opposed to 1) and the pline angle is such that the runs through more of the attribute the higher chance the program will work.
Please remember when testing to use different angles and different attribute values...I'm sure you will get the same results....If anyone is interested I'll post the block in the customer files named note-circle Also, I'm using WinXP & 2000i
Thanks!!
Eugene
I thought I had this all figured out with lots of help from the NG (thanks). After further testing I see the problem isn't really fixed..... Here's the program; Draw a pline from point 1 to point 2, (points are user defined) Place a block w/ attribute at point 2 (The block is a note symbol, such as a circle, square, hex, or triangle) User to edit block attribute Trim the pline from intersecting the block symbol.
Please see the code below.......................
;;; CIRLEADER.LSP
;;;
;;; DESCRIPTION:
;;;
;;; This routine draws a leader line with a circle block note symbol ;;; ;;;ERROR HANDLING ROUTINE ;;;;;;;;;;;;;;;;;
(defun myerror (s) ; If an error (such as CTRL-C) occurs while this command is active... (if (/= s "Function cancelled") (princ (strcat "\nError: " s)) ) (setvar "cmdecho" icm) ; Restore saved modes (setvar "filedia" ifd) (setvar "cmddia" icd) (setvar "cecolor" "bylayer") (setq *error* olderr) ; Restore old *error* handler (princ)
)
;--MAIN PROGRAM------------------------------
(defun dtr (ang1) ;converts degrees to radians (because AutoCAD (* pi (/ ang1 180.0)) ;works in dergees & AutoLISP works in radians)
)
(defun ALE_LASTENT ( / ename result )
(and
(setq result (entlast))
(while (setq ename (entnext result)) (setq result ename)) ) result )
(defun ALE_SS-AFTER (ename / ss)
(cond
( (eq 'ename (type ename))
(setq ss (ssadd))
(while (setq ename (entnext ename))
(if (entget ename) (ssadd ename ss)))
(if (< 0 (sslength ss)) ss)
)
( T (alert "Attention: error in selection set (lastent)") )
) )
(defun c:cirleader (/ olderr ec as pa pm p1 p2 sz ad marker ) (setq olderr *error* *error* myerror) (setq ec (getvar "cmdecho")) (setvar "cmdecho" 0) (setq as (getvar "autosnap")) (setq pa (getvar "polarang")) (setq pm (getvar "polarmode")) (command "ucs" "view") (setvar "autosnap" 47) (setvar "polarang" 0.523598776) ;30 degrees (setvar "polarmode" 2) (setq p1 (getpoint "\nPick Leader Start...")) (setq p2 (getpoint p1 "\nPick Note Location...")) (setq sz (getvar "dimscale")) ;(command "ucs" "Previous") (setvar "autosnap" as) (setvar "polarang" pa) (setvar "polarmode" pm) (setvar "cmdecho" ec) (command "pline" p1 p2 nil) (setq ad (getvar "attdia")) (setvar "attdia" 1) (setq marker (ALE_LASTENT)) (command "-insert" "note-circle" p2 sz sz "0" ) (command "trim" (ALE_SS-AFTER marker) "" p2 nil ) (setvar "attdia" ad) (command "ucs" "Previous")
(princ)
)
I think the program is using the attribute for the trimming edge selection not the block....supporting reason; Trimmed pline is sporadic...sometimes it trims, sometimes it doesn't Seems to depend on the pline angle and attribute value if the pline is trimmed or not... Seems if the attribute value takes up more block real-estate (ie 00 opposed to 1) and the pline angle is such that the runs through more of the attribute the higher chance the program will work.
Please remember when testing to use different angles and different attribute values...I'm sure you will get the same results....If anyone is interested I'll post the block in the customer files named note-circle Also, I'm using WinXP & 2000i
Thanks!!
Eugene