guitarguy1685 Posted January 10, 2010 Posted January 10, 2010 It's me again with another question. I'm writing a lisp that inserts a block and if you choose you can tag it with a leader which has another block w/ attribute text automatically filled in. The block with the attribute text is a simple dynamic block with 1 extra point for insertion. so when you get to the point of inserting the attribute block you can just press *CTRL* to cycle through the to insertion points which are right or left. what I would like to do in my lisp is define which side to use. Here is my logic. P1(x1,y1) is the insertion point of the block to be detailed. P2(x2,y2) is the point of my leader landing if x2 >= x1 then use right side (original insertion point), else use left side (2nd point defind by dynamic block) the first part is easy. i'll just use P2 as the point to insert. it's the 2nd option. I need to tell autocad to first use the 2nd point as insertion point, then insert it at P2. Is this possible? I suppose I could make 2 blocks, one with right side insert and one with left side. I'd rather have one but if I need 2 i will. ;;;--------------------------------------------------------- ;;; ;;;under development ;;; ;;;--------------------------------------------------------- (defun C:FPJ1 (/ ) (setq CRcecho (getvar "cmdecho")) ;;;store curret sysvar (setq CRdimas (getvar "dimassoc")) (setvar "cmdecho" 0) (setvar "dimassoc" 2) (setq CRdmsty (getvar "DIMSTYLE")) ;------------------------------------------------------------------------ (setq *error* ;;;resets sysvar incase of (lambda (msg) ;;;an error, esc, exit, cancel (setvar "cmdecho" CRcecho) (setvar "dimassoc" CRdimas) (command "-dimstyle" "r" CRdmsty) (princ msg) (princ))) ;------------------------------------------------------------------------ (setq FPTag "C:/Documents and Settings/TEMP/My Documents/LISP/fpart/fpart") (setq FPPaP "C:/Documents and Settings/TEMP/My Documents/LISP/fpart/F") (or *FPnameG* (setq *FPnameG* "?")) (setq CRuprec (getvar "LUPREC")) (setq CRLunit (getvar "LUNITS")) (or (eq "" (setq tmp (getstring (strcat "\nF-Part to insert <" *FPnameG* ">: ")))) (setq *FPnameG* tmp)) (setq FPPath (strcat FPPaP *FPnameG*)) (initget "Yes No") (setq TagAns (getkword (strcat "\nTag Fpart? [Yes/No] <No>: "))) (if (/= TagAns "Yes") (progn (setq FPP1 (getpoint "\nSpecify insertion point: ")) (command "-insert" FPPath FPP1 "1" "1" pause)) (progn (setq FPAtTxt (strcase (strcat "F" (substr *FPnameG* 1 2) "." (substr *FPnameG* 3 2)))) (setq FPP1 (getpoint "\nSpecify insertion point: ")) (command "-insert" FPPath FPP1 "1" "1" pause) (command "-dimstyle" "r" "leader") (setq CRDSCL (getvar "DIMSCALE")) (initget 6) (setq FPDSCL (cond ((getreal (strcat "\nSpecify scale factor <" (rtos CRDSCL CRLunit CRuprec) ">: "))) (CRDSCL))) (setq FPLP1 (getpoint "\nSpecify point of leader landing")) (if (<= (car FPLP1) (car FPP1)) (setq FPLP2 (list (- (car FPLP1) 0.125) (cadr FPLP1))) (setq FPLP2 (list (+ (car FPLP1) 0.125) (cadr FPLP1))) ) (princ "\n>>Press *Ctrl* to cycle insertion point") (command "_.leader" FPP1 FPLP1 FPLP2 "" "" "b" FPTag pause FPDSCL FPDSCL "0" FPAtTxt))) ;-------------------------------------------------------------------------- (setvar "cmdecho" CRcecho) ;;;restore previous settings (command "-dimstyle" "r" CRdmsty) (princ) ) fpart.dwg Quote
Lee Mac Posted January 11, 2010 Posted January 11, 2010 Perhaps this may give you some inspiration (defun c:test ( / BLK BOBJ DOC P1 P2 P3 SPC) (vl-load-com) (setq blk "fpart") ;; Block Name (setq doc (cond (doc) ((vla-get-ActiveDocument (vlax-get-Acad-Object)))) spc (if (zerop (vla-get-activespace doc)) (if (= (vla-get-mspace doc) :vlax-true) (vla-get-modelspace doc) (vla-get-paperspace doc)) (vla-get-modelspace doc))) (defun Make_Leader (p1 p2 p3) (entmakex (list (cons 0 "LEADER") (cons 100 "AcDbEntity") (cons 100 "AcDbLeader") (cons 71 1) (cons 72 0) (cons 73 3) (cons 74 0) (cons 75 0) (cons 10 p1) (cons 10 p2) (cons 10 p3) (list -3 (list "ACAD" (cons 1000 "DSTYLE") (cons 1002 "{") (cons 1070 41) ;; ArrowSize (cons 1040 0.125) (cons 1002 "}")))))) (cond ( (not (or (tblsearch "BLOCK" blk) (setq blk (findfile (strcat blk ".dwg"))))) (princ "\nBlock Not Found: ")) ( (not (and (setq p1 (getpoint "\nSpecify First Point: ")) (setq p2 (getpoint "\nSpecify Leader Landing: " p1))))) ( (Make_Leader p1 p2 (setq p3 (polar p2 (if (< (car p1) (car p2)) 0 pi) 0.125))) (if (vl-catch-all-error-p (setq bObj (vl-catch-all-apply (function vla-insertblock) (list spc (vlax-3D-point p3) blk 1. 1. 1. 0.)))) (princ "\n** Error inserting Block **") (if (and (eq :vlax-true (vla-get-isDynamicblock bObj)) (> (car p2) (car p1))) (progn (vla-put-insertionPoint bObj (vlax-3D-point (mapcar (function -) p3 (mapcar (function vlax-variant-value) (mapcar (function vla-get-value) (vlax-safearray->list (vlax-variant-value (vla-getDynamicBlockProperties bObj))))))))))))) (princ)) Quote
guitarguy1685 Posted January 11, 2010 Author Posted January 11, 2010 lol that's F****** awesome. now i tried to look up some of the commands you used but they are not listed in the acad help files. Like vla-insertblock. it's not listed. where can I get a list of these commands. Quote
BearDyugin Posted January 11, 2010 Posted January 11, 2010 where can I get a list of these commands. Look in the help ActiveX and VBA Reference As a rule for Lisp method -> vla-method property -> vla-put\get-property Quote
Lee Mac Posted January 11, 2010 Posted January 11, 2010 lol that's F****** awesome. now i tried to look up some of the commands you used but they are not listed in the acad help files. Like vla-insertblock. it's not listed. where can I get a list of these commands. Haha glad you like it As GeoBuilder says, type vla-insertblock in the VLIDE and double-click on it to highlight the whole word, then click on the help icon. This may give you some insight: http://www.cadtutor.net/forum/showpost.php?p=258403&postcount=9 Quote
BearDyugin Posted January 11, 2010 Posted January 11, 2010 double-click on it to highlight the whole word, then click on the help icon. As, instead of "сick on the " after highlight the whole word, it is possible Ctrl+F1 Quote
LEsq Posted January 11, 2010 Posted January 11, 2010 or... while on the vlide editor - click on the apropos options (A) - type the name of the function or the first letter like vla- vlax- etc... or use the available search options - and highlight under apropos results the function name - and click on the help icon there are some functions left over from the original vital lisp, like vlax-get, vlax-put, etc.... that are now undocumented hth.- Quote
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.