shailujp Posted November 1, 2013 Posted November 1, 2013 Hi all, There are five sheet sizes A, B , C, D, E. The xref file name is under \drawing\formats\A00.dwg (b00.dwg, C00.dwg etc...) for each sheet size. Currently I have a small block insertion utility which requires manual look-up (visually) of the sheet size and then choose the size of block insertion required and then fill up the attributes. So, I made commands like BLKA, BLKB, BLKC, BLKD, BLKE separately. This is because I do not know how to search for the X-ref file name (not the x-ref name) and then use that as a variable to automatically insert using the block and attributes using just one command. Any suggestions? Quote
shailujp Posted November 5, 2013 Author Posted November 5, 2013 Can someone please provide me a way to resolve this? Quote
BIGAL Posted November 6, 2013 Posted November 6, 2013 Sounds like your not using layouts, once you create one with correct title block then just use copy to add another sheet, generally about 90% is the same per sheet, also look into sheet set manager. If you only have 5 sheets sizes why not just have them all in your template just delete the blank layouts once you know wher your heading. Quote
shailujp Posted November 6, 2013 Author Posted November 6, 2013 Thanks BIGAL for your suggestion. We do have company templates but only few project requires inserting additional blocks and there are many people uses that sheet so I have no control over original templates to modify it. Thats the reason, I'm limited to insert the size specific block (which is not the title block) it the additional information pertaining to the drawing. Once I insert the block, I fill up few attributes (which is thru lisp) so I was wondering, if AutoCAD can somehow look-up the sheet size thru xref properties and insert the block accordingly. I can complete (or atleast try to build) my code but not sure how to look-up sheet size. Any Idea on how ot look-up the sheet size? (Defun C:blka () (command "layout" "" "") (setvar "cmdecho" 0) (setvar "attreq" 0) (Command "-INSERT" "XXXX/XXXX/BLOCK_A" "0,0" "" "" "") (princ "\nSelect Text file for attribute import:") (c:attin) (setvar "attreq" 1) (princ "\nAttributes copied & Updated") (command "eattedit" "L") (princ) ) Quote
shailujp Posted November 19, 2013 Author Posted November 19, 2013 Can someone please provide me some guidance in this so that I can atleast try something on this? Thanks Quote
shailujp Posted November 20, 2013 Author Posted November 20, 2013 Here is a snap of the property manager where it lists down xref path. Quote
pBe Posted November 20, 2013 Posted November 20, 2013 Not sure what you're after shailujp, If the files you are after is within a folder listed in your SFSP [support File Search Path] then you wont have any problems inserting the required block, just make sure when supplying the filename as argument for command insert to include findfile i.e. (findfile "d00.dwg") ..not sure how to look-up sheet size... That i dont understand at all Quote
shailujp Posted November 20, 2013 Author Posted November 20, 2013 I want to have lisp look-up somehow xref block path name and then it should decide to insert suitable another block (different name) in my drawing. Between all the xref's the only unique name I found was a file path name. I'm trying to retrieve that information somehow and store as variable and then insert another block and fill attributes and so on.... Please let me know if I'm still not making sense with this. Quote
pBe Posted November 20, 2013 Posted November 20, 2013 what does this snippet show you (while (setq a (tblnext "BLOCK" (null a))) (if (assoc 1 a) (print (cdr (assoc 1 a)) ) ) ) Quote
shailujp Posted November 21, 2013 Author Posted November 21, 2013 It returns this. Spot on pBe. Command: xtest "\\drawings\\formats\\b00.dwg" nil Command: Can you please explain the code? I'm thinking I dont need "while" since there will be one xref block in each drawing. Is this correct? EDIT :I tried removing while but then it started returning NIL. Now I need to find a way to use this info as a variable and set Cond for all sizes. Quote
pBe Posted November 21, 2013 Posted November 21, 2013 Spot on pBe. Can you please explain the code? I'm thinking I dont need "while" since there will be one xref block in each drawing. Is this correct? Now I need to find a way to use this info as a variable and set Cond for all sizes. The way i see it, there are two ways you an do this with vanilla., 1. Use Tblnext until it finds an xref , only thing is , if the xref were somehow deleted and not purge, the item item will still show on the table 2. Use ssget "X", You still need to iterate thru the selection until it finds an xref. For both options you can use the while function to terminate the loop if xref is found. Now if you combined both and also the using the names of every sheet size block Just for the fun of it, i also wrote a quick code for both (defun xrefet (blk / a f) (while (and (setq a (tblnext "BLOCK" (null a))) (null f) ) (if (and (assoc 1 a) (wcmatch (cdr (assoc 2 a)) blk) (ssget "_X" (list (assoc 2 a))) ) (setq f (cdr (assoc 1 a))) ) ) f ) (XREFET "A00,B00,C00,D00") (defun xrefes (blk / ss i sl a en f) (if (and (setq f nil i -1 ss (ssget "_X" (list '(0 . "INSERT") (cons 2 blk) ) ) ) (setq sl (sslength ss)) ) (while (and (null f) (< i sl)) (setq f (if (and (setq en (cdr (assoc 2 (entget (ssname ss (setq i (1+ i)))))) ) (setq f (assoc 1 (tblsearch "BLOCK" en))) ) (cdr f) nil ) ) ) ) ) (XREFES "A00,B00,C00,D00") Not sure how [XREFET] will fair against [XREFES] but i'm guessing the latter is faster Quote
shailujp Posted November 23, 2013 Author Posted November 23, 2013 pBe, Both the codes returns "; error: too few arguments" I think this line is not working (if (and (assoc 1 a) (wcmatch (cdr (assoc 2 a)) blk) (ssget "_X" (list (assoc 2 a))) ) So I removed that line and build my code with cond function. This currently works as is but not sure if this is correct since I removed fool proofing. (Defun C:XTEST (/ a f blkname) (command "layout" "" "") (setvar "cmdecho" 0) (setvar "attreq" 0) (while (and (setq a (tblnext "BLOCK" (null a))) (null f) ) (if (assoc 1 a) (setq f (cdr (assoc 1 a))) ) ) (cond ((= f "[url="file://drawings//formats//b00.dwg"]\\drawings\\formats\\b00.dwg[/url]") (setq blkname "J_Logo_B")) ((= f "[url="file://drawings//formats//c00.dwg"]\\drawings\\formats\\c00.dwg[/url]") (setq blkname "J_Logo_C")) ((= f "[url="file://drawings//formats//d00.dwg"]\\drawings\\formats\\d00.dwg[/url]") (setq blkname "J_Logo_D")) ((= f "[url="file://drawings//formats//e00.dwg"]\\drawings\\formats\\e00.dwg[/url]") (setq blkname "J_Logo_E")) ((= f "[url="file://drawings//formats//j00.dwg"]\\drawings\\formats\\j00.dwg[/url]") (setq blkname "J_Logo_J")) ) (Command "-INSERT" blkname "0,0" "" "" "") (princ "\nSelect Text file for attribute import:") (c:attin) (setvar "attreq" 1) (princ "\nAttributes copied & Updated") (command "eattedit" "L") (princ) ) Also (setq f (cdr (assoc 1 a))) returns "\\drawings\\formats\\d00.dwg". Due to this, under cond, I had to add full path with .dwg. Is there anyway to return just d00 (not location & not extension)? Thanks, Quote
shailujp Posted November 27, 2013 Author Posted November 27, 2013 pBe, Adding to my last post, the code that I modified only works with a blank new drawing (just with template). If this utility is run on an existing drawing which contains several different blocks, it fails. It seems like its not able to just filter THE xref block from the whole drawing. Please suggest. Quote
pBe Posted November 29, 2013 Posted November 29, 2013 pBe, Both the codes returns "; error: too few arguments"..... Because you did not supply the correct number of arguments (XREFET "A00,B00,C00,D00"); (XREFES "A00,B00,C00,D00"); pBe, .....I had to add full path with .dwg. Is there anyway to return just d00 (not location & not extension)? Demo: (vl-filename-base (getvar 'dwgname)) pBe, Adding to my last post, the code that I modified only works with a blank new drawing (just with template). If this utility is run on an existing drawing which contains several different blocks, it fails. It seems like its not able to just filter THE xref block from the whole drawing. Please suggest. Try the code at post # 11 with the correct arguments HTH Quote
shailujp Posted December 3, 2013 Author Posted December 3, 2013 pBe, I think I'm confused. Here is what I understand from this (argument). It looks like that you created a Sub function (is this true?) and then you are calling out subfunction into the main function that time you are adding arguments along with it? And I was making it a part of the main routine. Is it possible the way I was attempting it? Or it has to be thru subfunction? 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.