pmxcad Posted February 21, 2012 Posted February 21, 2012 Hello, I found a lisp (av.lsp) on the web for turnning attributes on or off. This lisp can do just one tag and al the blocks with TAG1. Is it possible to rebild the lisp so that i can used it with a script so that i can select multiple blocks and Tag`s. Like: AV blockname1,blockname2 etc etc TAG1,TAG2,TAG3 etc etc off or on Thanks, PmxCAD AV.LSP Quote
pBe Posted February 22, 2012 Posted February 22, 2012 You mean toggle on/off TAG1 for Blockname1... TAG2 for Blockname2..? or find all listed tags for all listed Blocknames? Quote
pmxcad Posted February 22, 2012 Author Posted February 22, 2012 Hello pBe, I like to choose the blocks (by block name) and the tags who has to be turned off or on. So it can be like, BLOKNAME1 and tags TAG1 & TAG4 or something like that. It alsp can be more blocks and just 1 TAG to be turned off or on. I think find all tags for all listed blocknames. PmxCAD Quote
pBe Posted February 22, 2012 Posted February 22, 2012 (edited) try this: (defun Togomoff (blst tglst mode / bn ss e) (setq bn (mapcar (function (lambda (j) (strcat j ","))) blst)) (if (setq ss (ssget "_X" (list '(0 . "INSERT") '(66 . 1) (cons 2 [color=blue](strcat [/color](apply 'strcat bn) [color=blue]"`*U*")[/color])))) (repeat (sslength ss) (if [color=blue](member (strcase (vla-get-effectivename (setq e (vlax-ename->vla-object (ssname ss 0))))) (mapcar 'strcase blst)) [/color] (foreach itm (vlax-invoke e 'GetAttributes) (if (member (vla-get-tagstring itm) tglst) (vla-put-invisible itm mode)) ) ) (ssdel (ssname ss 0) ss) ) )(princ) ) script file (setq blocklst '("Blockname1" "Blockname2" "Blockname3" "Blockname4")) (setq taglist '("TAG1" "TAG2" "TAG3" "TAG4" "TAG5" "TAG6")) (vl-propagate 'blocklst) (vl-propagate 'taglist) _.open "C:\Folderpath\sample1.dwg" (Togomoff blocklst taglist 1) _.save _Y _.close _.open "C:\Folderpath\sample2.dwg" (Togomoff blocklst taglist 0) _.save _Y _.close _.open "C:\Folderpath\sample3.dwg" (Togomoff blocklst taglist 1) _.save _Y _.close "Note that the prompts and their order may change from version to version" And i believe you know enough of lisp to figure out how to load the routine: (Togomoff blocklst taglist 1) Where 1 or 0 is the toggle What it does is search the drawing file for the listed blocknames [/i] and each block found will be tested for tagnames [/i] HTH CODE UPDATED : Missing loop flag / to include Anonymous name Edited February 22, 2012 by pBe CODE UPDATED Quote
pmxcad Posted February 22, 2012 Author Posted February 22, 2012 pBe, Looks good i gues, but i dont gone use the last part of the script where looking for a drawing file. I used it on an open drawing, and i`am using Acad Electrical 2010 & 2012 and i can do projectwide tools/scripts on selected drawings. PmxCAD Quote
pBe Posted February 22, 2012 Posted February 22, 2012 pBe,Looks good i gues, but i dont gone use the last part of the script where looking for a drawing file. I used it on an open drawing, and i`am using Acad Electrical 2010 & 2012 and i can do projectwide tools/scripts on selected drawings. PmxCAD .... Did it work for you? were you able to succesfully run the program? Quote
pmxcad Posted February 22, 2012 Author Posted February 22, 2012 Sorry pBe, no it didn`t. I don`t know how to change the lisp or script to change the last part of the script for looking for a drawing file. I have erased the last 3 rules of the script but that isn`t working. So can je help me? So want it to use it on an open drawing. PmxCAD Quote
pBe Posted February 22, 2012 Posted February 22, 2012 like this (Togomoff '("Blockname1" "Blockname2" "Blockname3" "Blockname4") '("TAGNAME1" TAGNAME2" TAGNAME3" TAGNAME4" TAGNAME5") 1) (setq blocklst '("Blockname1" "Blockname2" "Blockname3" "Blockname4")) (setq taglist '("TAG1" "TAG2" "TAG3" "TAG4" "TAG5" "TAG6")) (Togomoff blocklst taglist 1);<--- 1 turn off visibility 0 on visibility Or we can include the block/tag list hardcoded on the lisp and use command: Togomoff Would you still want to be prompted for ON / OFF for every tag name? If you can provide a sample drawing, or provide a blockname and a tagname list so i can show you how. Quote
pmxcad Posted February 22, 2012 Author Posted February 22, 2012 pBe i found the solution; (setq blocklst '("RMELDER")) (setq taglist '("TAG1")) (vl-propagate 'blocklst) (vl-propagate 'taglist) (Togomoff blocklst taglist 0) This works for me. many thanks for your help. PmxCAD Quote
pBe Posted February 22, 2012 Posted February 22, 2012 pBe i found the solution;...... ....... PmxCAD if you are running this routine on a open drawing you dont need the vl-propagate lines. vl-propagate by definition: Copies the value of a variable into all open document namespaces (and sets its value in any subsequent drawings opened during the current AutoCAD session) Since you are not going to use it on a script. a single decalaration of the variable is enough: (setq blocklst '("RMELDER")) (setq taglist '("TAG1")) or directly using the list as arguments (Togomoff '("RMELDER")("TAG1") 0); (Togomoff '("RMELDER")("TAG1") 1); Got it? Quote
pBe Posted February 22, 2012 Posted February 22, 2012 Yep, ..............thanks Okeedokee, Holler if you need help Cheers BTW: for opened drawing you can always use command: BATTMAN Quote
pmxcad Posted February 22, 2012 Author Posted February 22, 2012 pBe,......... little problem. It not working on al the blocks with the same name, just one. I working with dynamic blocks, is this the problem? PmxCAD Quote
pBe Posted February 22, 2012 Posted February 22, 2012 pBe,......... little problem.It not working on al the blocks with the same name, just one. I working with dynamic blocks, is this the problem? PmxCAD Yes it is.... Glad you caught it really. Good catch PmxCAD CODE UPDATED: Quote
pmxcad Posted February 22, 2012 Author Posted February 22, 2012 Superrrrrrrrrrr....................... it works. Is this because of the virtual names that Autocad create for dynamic blocks? PmxCAD Quote
pBe Posted February 22, 2012 Posted February 22, 2012 Superrrrrrrrrrr....................... it works.Is this because of the virtual names that Autocad create for dynamic blocks? PmxCAD Yup.. commonly known as Anonymous name.. [Dynamic blocks].... Once you change the visibilty of DB the names get all hosed up.. Cheers PmxCAD Glad i could help 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.