Spinxy Posted March 21, 2013 Posted March 21, 2013 Hi I made a macro back in the days of customizing my buttons. which set the layer, promted you to make a rectangle, promted you to select the triangle to convert it a rev cloud (which i may be able to cut that promt out by using last) then inserts a rev triangle and prompts you for insersion point, then puts the layer back to what it was previously Below is my maro code, hope i am inserting this correctly. i would like to make this a lisp, so that i can get it to run by typing "revc" any help would be much appreciated, i would also like to do this for inserting some simpler blocks. ^C^C(setq a(getvar "clayer"));-layer;M;Revision;;rectang;\\revcloud;a;10;10;;\;-Insert;"Rev_Tri.dwg";\1;1;0;-layer;S;!a;; Quote
Tharwat Posted March 22, 2013 Posted March 22, 2013 Try this Spinxy . (defun c:Test (/ *error* c cm p p1 p2) ;;---- Tharwat 22. march. 2013 ----;; (defun *error* (x) (if c (setvar 'clayer c) ) (princ "\n*Cancel*") ) (if (not (tblsearch "BLOCK" "Rev_Tri.dwg")) (progn (alert " Block name < Rev_Tri.dwg > is not found !") (exit) ) ) (setq c (getvar 'clayer)) (if (not (tblsearch "LAYER" "Revision")) (entmakex (list '(0 . "LAYER") '(100 . "AcDbSymbolTableRecord" ) '(100 . "AcDbLayerTableRecord" ) '(2 . "Revision") '(70 . 0) ) ) ) (if (and (progn (princ "\n Rectang") (setq p1 (getpoint "\n Specify first corner :")) ) (setq p2 (getcorner "\n Specify other corner point :" p1)) ) (progn (setq cm (getvar 'cmdecho)) (mapcar 'setvar '(cmdecho clayer) (list 0 "Revision")) (vl-cmdf "_.rectang" "_none" p1 "_none" p2) (vl-cmdf "_.revcloud" "_a" 10. 10. "" (entlast) "") (mapcar 'setvar '(cmdecho clayer) (list 1 c)) ) ) (if (setq p (getpoint "\n Specify insertion point for Block :")) (entmakex (list '(0 . "INSERT") '(2 . "Rev_Tri.dwg") (cons 10 (trans p 1 0)) '(8 . "Revision") '(41 . 1.0) '(42 . 1.) '(43 . 1.) ) ) ) (princ) ) (vl-load-com) Quote
Spinxy Posted March 24, 2013 Author Posted March 24, 2013 Hi Tharwat, Thanks so much for the quick response, i had to wait till this morning to try it out. it's not finding the block, the block is in a folder which is pathed in my support file search path and the names are matching, any ideas what i have done wrong? Really appreciate you giving that a go thanks Quote
Tharwat Posted March 25, 2013 Posted March 25, 2013 You're welcome , Actually the routine does not look for the block outside the drawing , but we can add that option to the code if you can bring the complete path of the Block . Quote
Spinxy Posted March 25, 2013 Author Posted March 25, 2013 Hey i also tried inserting the block into the drawing and tried it again, but it still didn't find the block The path in this instance is H:\My Documents Sydney\AutoCAD\Blocks\My Blocks I may want to edit this at a later date so that it can be used by others in the office. Thanks Quote
Tharwat Posted March 25, 2013 Posted March 25, 2013 (edited) H:\My Documents Sydney\AutoCAD\Blocks\My Blocks Is it correct that there is not any back slash before the word Sydney ? Besides that , I considered that the My Blocks is the drawing that contains the needed blocks . Try this at the moment . (defun c:Test (/ *error* c cm p p1 p2) ;;---- Tharwat 25. march. 2013 ----;; (defun *error* (x) (if c (setvar 'clayer c) ) (princ "\n*Cancel*") ) (if (not (tblsearch "BLOCK" "Rev_Tri.dwg")) (command "_.insert" "H:\\My Documents Sydney\\AutoCAD\\Blocks\\My Blocks.dwg" nil) ) (if (not (tblsearch "BLOCK" "Rev_Tri.dwg")) (progn (alert "The Block name < Rev_Tri.dwg > is not found in the attached drawing !!") (exit)) ) (setq c (getvar 'clayer)) (if (not (tblsearch "LAYER" "Revision")) (entmakex (list '(0 . "LAYER") '(100 . "AcDbSymbolTableRecord") '(100 . "AcDbLayerTableRecord") '(2 . "Revision") '(70 . 0) ) ) ) (if (and (progn (princ "\n Rectang") (setq p1 (getpoint "\n Specify first corner :"))) (setq p2 (getcorner "\n Specify other corner point :" p1)) ) (progn (setq cm (getvar 'cmdecho)) (mapcar 'setvar '(cmdecho clayer) (list 0 "Revision")) (vl-cmdf "_.rectang" "_none" p1 "_none" p2) (vl-cmdf "_.revcloud" "_a" 10. 10. "" (entlast) "") (mapcar 'setvar '(cmdecho clayer) (list 1 c)) ) ) (if (setq p (getpoint "\n Specify insertion point for Block :")) (entmakex (list '(0 . "INSERT") '(2 . "Rev_Tri.dwg") (cons 10 (trans p 1 0)) '(8 . "Revision") '(41 . 1.) '(42 . 1.) '(43 . 1.) ) ) ) (princ) ) (vl-load-com) Edited March 25, 2013 by Tharwat Quote
Spinxy Posted March 25, 2013 Author Posted March 25, 2013 Getting there, I don't get the error now, it gets to the point of inserting the block, i choose a point and nothing. Below is where my command line gets to Command: test _.insert Enter block name or [?] : H:\My Documents Sydney\AutoCAD\Blocks\Rev_Tri.dwg Specify insertion point or [basepoint/Scale/X/Y/Z/Rotate]: Command: Rectang Specify first corner : Specify other corner point : Minimum arc length: 10.0000 Maximum arc length: 10.0000 Style: Normal Revision cloud finished. Specify insertion point for Block : Quote
Tharwat Posted March 25, 2013 Posted March 25, 2013 What is the name of the Block that MUST be included within the drawing name My Blocks ? Is it Rev_Tri or anything else ? Quote
Spinxy Posted March 25, 2013 Author Posted March 25, 2013 it's "Rev_Tri.dwg" which i had to update from myblocks in your last script. Quote
Tharwat Posted March 25, 2013 Posted March 25, 2013 it's "Rev_Tri.dwg" which i had to update from myblocks in your last script. Type the command name insert and search that block name , is it with .dwg ? Quote
Tharwat Posted March 25, 2013 Posted March 25, 2013 CODES UPDATED in post No #6 , try it and let me know how did you get on with the code . Quote
Spinxy Posted March 25, 2013 Author Posted March 25, 2013 Nearly there, I have updated the path and block name removing the .dwg it does everything now apart from automatically open the attributed text (within the Block) for editing once it's inserted. If this is difficult i could just replace the attributed text with single line text. i have attached the drawing i have been testing it in, which has the block attached if it helps. Thanks (defun c:Test (/ *error* c cm p p1 p2) ;;---- Tharwat 25. march. 2013 ----;; (defun *error* (x) (if c (setvar 'clayer c) ) (princ "\n*Cancel*") ) (if (not (tblsearch "BLOCK" "Rev_Tri.dwg")) (command "_.insert" "H:\\My Documents Sydney\\AutoCAD\\Blocks\\my blocks\\Rev_Tri.dwg" nil) ) (setq c (getvar 'clayer)) (if (not (tblsearch "LAYER" "Revision")) (entmakex (list '(0 . "LAYER") '(100 . "AcDbSymbolTableRecord") '(100 . "AcDbLayerTableRecord") '(2 . "Revision") '(70 . 0) ) ) ) (if (and (progn (princ "\n Rectang") (setq p1 (getpoint "\n Specify first corner :"))) (setq p2 (getcorner "\n Specify other corner point :" p1)) ) (progn (setq cm (getvar 'cmdecho)) (mapcar 'setvar '(cmdecho clayer) (list 0 "Revision")) (vl-cmdf "_.rectang" "_none" p1 "_none" p2) (vl-cmdf "_.revcloud" "_a" 10. 10. "" (entlast) "") (mapcar 'setvar '(cmdecho clayer) (list 1 c)) ) ) (if (setq p (getpoint "\n Specify insertion point for Block :")) (entmakex (list '(0 . "INSERT") '(2 . "Rev_Tri") (cons 10 (trans p 1 0)) '(8 . "Revision") '(41 . 1.) '(42 . 1.) '(43 . 1.) ) ) ) (princ) ) (vl-load-com) Rev_Cloud.dwg Quote
Tharwat Posted March 26, 2013 Posted March 26, 2013 (edited) Check this out now and let me know how the codes worked for you ... (defun c:Test (/ *error* c r d cm p p1 p2 st) ;;---- Tharwat 27. March. 2013 ----;; (defun *error* (x) (setvar 'cmdecho 1) (if r (setvar 'attreq r) ) (if d (setvar 'attdia d) ) (if c (setvar 'clayer c) ) (princ "\n*Cancel*") ) (if (not (tblsearch "BLOCK" "Revision")) (command "_.insert" "H:\\My Documents Sydney\\AutoCAD\\Blocks\\My Blocks.dwg" nil) ) (if (not (tblsearch "BLOCK" "Revision")) (progn (alert "The Block name < Revision > is not found in the attached drawing !!") (exit)) ) (setq c (getvar 'clayer) r (getvar 'attreq) d (getvar 'attdia) ) (if (not (tblsearch "LAYER" "Revision")) (entmakex (list '(0 . "LAYER") '(100 . "AcDbSymbolTableRecord") '(100 . "AcDbLayerTableRecord") '(2 . "Revision") '(70 . 0) ) ) ) (if (and (progn (princ "\n Rectang") (setq p1 (getpoint "\n Specify first corner :"))) (setq p2 (getcorner "\n Specify other corner point :" p1)) ) (progn (setq cm (getvar 'cmdecho)) (mapcar 'setvar '(cmdecho attreq attdia clayer) (list 0 1 0 "Revision")) (vl-cmdf "_.rectang" "_none" p1 "_none" p2) (vl-cmdf "_.revcloud" "_a" 10. 10. "" (entlast) "") ) ) (if (setq st (getstring "\n Specify Attributed string :")) (progn (command "_.-insert" "Revision" pause "" "" st) (mapcar 'setvar '(cmdecho attreq attdia clayer) (list 1 r d c)) ) ) (princ) ) (vl-load-com) Edited March 27, 2013 by Tharwat Quote
Spinxy Posted March 27, 2013 Author Posted March 27, 2013 Thanks It's now working if i already have the block in the drawing, is it possible we could do it so that it takes it from a selected folder? The insertion point of the block has changed to the center of the block, could we put this back the original corner or even better would be to be able to see the block as your inserting it. hope i'm not being a pain, it's just i like to have the triangle slightly over lap the cloud it's relating to and this becomes hard if you can't see the block on insertion. Great work, i was hoping to be able to edit this for a simpler block insert but even this code is way past my level! Quote
Tharwat Posted March 27, 2013 Posted March 27, 2013 ThanksIt's now working if i already have the block in the drawing, is it possible we could do it so that it takes it from a selected folder? The insertion point of the block has changed to the center of the block, could we put this back the original corner or even better would be to be able to see the block as your inserting it. hope i'm not being a pain, it's just i like to have the triangle slightly over lap the cloud it's relating to and this becomes hard if you can't see the block on insertion. Great work, i was hoping to be able to edit this for a simpler block insert but even this code is way past my level! I updated the last posted codes ( post No# 13 ) , so try it and let me know how it goes . Quote
Spinxy Posted March 28, 2013 Author Posted March 28, 2013 It's working. Thanks so much for that. it will be a well used tool. Now i was hoping to be able to do this one myself, but the code is a lot harder than i expected. could you do me another code with just the layer set and and block insert so i can use for a simple RFI tag on as built drawings, no worries if you don't want to you have already helped me enough. Thanks Quote
Tharwat Posted March 28, 2013 Posted March 28, 2013 It's working.Thanks so much for that. it will be a well used tool. Excellent , you're welcome anytime . could you do me another code with just the layer set and and block insert so i can use for a simple RFI tag on as built drawings Can you please explain your aim of the code more in details to allow me to give you the appropriate codes from the first post ? 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.