russell84 Posted April 7, 2008 Share Posted April 7, 2008 Hi I've been working on a dcl and lisp to insert a legend - attached is how far i have come. basically what i want to be able to do is have each toggle box insert a block that is made up of a simple symbol and description to be within a legend.(these blocks obviously within acad search path) So once desired toggles are selected and user selects ok the user select an initial insertion point and the the lisp would create a list of selected toggles and run through the list and insert the first block at the insertion point but then cycle through the list and insert each block (-2.5(Y)) units below the previously inserted block until the list is complete thus creating the legend. Could someone help me complete this function - i have tried and tried and don't know how to create the - 'make list from selected toggles and insert blocks' Have a look and please let me know the best way to go about this please. You will just have to change the extension of Legend.txt to Legend.DCL Cheers LEGEND.LSP LEGEND.txt Quote Link to comment Share on other sites More sharing options...
ASMI Posted April 7, 2008 Share Posted April 7, 2008 Nice work At first, HELP is reserved name of lisp function. Change it to other name for example: (defun [color="Blue"]help1[/color] () (alert (strcat "TYPE HELP GUIDE HERE" "\n\nTYPE HELP GUIDE HERE")) ) You can continue your function something like: ;;;--- If the user pressed the Okay button (if(= ddiag 2) (progn (if(setq fPt(getpoint "\nSpecify legend insertion point: ")) ; specify top-left coner (progn (setq blLst '(("t1" "Block_Name1")("t2" "Block_Name2") ... ))) ; create list (foreach itm blLst ;foreach item of list checkup check-box value (if(get_tile(car itm)) ; if check-box is checked (command "-insert" ...); insert block (setq fPt(mapcar '- fpt (0.0 Delta 0.0))) ; calculate next insertion point ); end foreach ); end progn ); end if ) ) I hope you able to write it. Quote Link to comment Share on other sites More sharing options...
russell84 Posted April 7, 2008 Author Share Posted April 7, 2008 Thanks asmi - not bad so far hey Just after i sent it i changed the help to help1 But thanks for that That bit of code will definately help - i should be able to get through it all i think - cheers for that If not there are plenty of people on here that can lend a hand Quote Link to comment Share on other sites More sharing options...
russell84 Posted April 7, 2008 Author Share Posted April 7, 2008 this what you meant? - I have had a play around with it - just i'm unfamiliar with "car' and "itm" This gets as far as getting the insertion point then it just stops I still need help with this please Any advice from here? legend.LSP Quote Link to comment Share on other sites More sharing options...
ASMI Posted April 7, 2008 Share Posted April 7, 2008 It was simple example. I think you need something like this: (defun Block_insert (blName insPt / oldEcho insSca blPath sucFlg *error*) (defun *error* (msg) (setvar "cmdecho" 1) ); end of *error* (setq sucFlg T); end setq (setvar "cmdecho" 0) (if (not(tblsearch "block" blName)) (progn (if (setq blPath(findfile(strcat blName ".dwg"))) (command "-insert" blPath "_s" "1.0" insPt "0") (setq sucFlg nil) ); end if ); end progn (command "-insert" blName "_s" "1.0" insPt "0") ); end if (setvar "cmdecho" 1) sucFlg ); end of Block_insert ;;;--- If the user pressed the Okay button (if(= ddiag 2) (progn (if(setq fPt(getpoint "\nSpecify legend insertion point: ")) (progn (setq blLst '(("t1" "bt1")("t2" "bt2")("t3" "bt3")("t4" "bt4")("t5" "bt5")("t6" "bt6")("t7" "bt7")("t8" "bt8")("t9" "nt9")("t10" "bt10") ("t11" "bt11")("t12" "bt12")("t13" "bt13")("t14" "bt14")("t15" "bt15")("t16" "bt16")("t17" "bt17")("t18" "bt18")("t19" "bt19")("t20" "bt20") ("t21" "bt21")("t22" "bt22")("t23" "bt23")("t24" "bt24")("t25" "bt25")("t26" "bt26")("t27" "bt27")("t28" "bt28")("t29" "bt29")("t30" "bt30") ("t31" "bt31")("t32" "bt32")("t33" "bt33")("t34" "bt34")("t35" "bt35")("t36" "bt36")("t37" "bt37")("t38" "bt38")("t39" "bt39")("t40" "bt40") ("t41" "bt41")("t42" "bt42")("t43" "bt43")("t44" "bt44")("t45" "bt45")("t46" "bt46")("t47" "bt47")("t48" "bt48")("t49" "bt49")("t50" "bt50") ("t51" "bt51")("t52" "bt52")("t53" "bt53")("t54" "bt54")("t55" "bt55")("t56" "bt56")("t57" "bt57")("t58" "bt58")("t59" "bt59")("t60" "bt60") ("t61" "bt61")("t62" "bt62")("t63" "bt63")("t64" "bt64")("t65" "bt65")("t66" "bt66")("t67" "bt67")("t68" "bt68")("t69" "bt69")("t70" "bt20") ) errLst nil ); end setq (foreach itm blLst (if(get_tile(car itm)) (progn (if(Block_insert(cadr itm)fPt) (setq fPt(mapcar '- fpt (0.0 Delta 0.0))) (setq errLst(cons errLst(cadr itm))) ); end if ); end progn ); end if ); end foreach ); end progn ); end if ); end progn ); end if (if errLst (princ(strcat "ERROR. Blocks not found:\n" errLst)) ); end if Try to taste it, I did not check this code, but I think that should work. I have had a play around with it - just i'm unfamiliar with "car' and "itm" However it is one of basic functions of LISP. just i'm unfamiliar with " car ' and "itm" (foreach) = I know nothing about LISP Do not foget change Delta to value in (setq fPt(mapcar '- fpt (0.0 Delta 0.0))) Quote Link to comment Share on other sites More sharing options...
russell84 Posted April 9, 2008 Author Share Posted April 9, 2008 i got it to work - a lot simpler than we were looking at before anyways here it is - block names are the same as the toggles - so if toggle(t1) is selected block "t1" is inserted etc Can someone have a look at it please and give me back any comments? or ways to improve its working - thanks There seems to be a bug though- it overlaps some of the blocks on the same spot pending on what zoom level you are at..weird anyway to fix this??? Or a reason why it is doing it anyways if you get a chance this would be great I just attached some quick test blocks aswell so you can test the thing - just grad the Dcl from previous post cheers just i'm unfamiliar with " car ' and "itm" (foreach) = I know nothing about LISP And Asmi now i know a bit more about there uses - thankyou acad help guide LEGEND.LSP t1.dwg t2.dwg t3.dwg t4.dwg t5.dwg t6.dwg Quote Link to comment Share on other sites More sharing options...
ASMI Posted April 9, 2008 Share Posted April 9, 2008 Tomorow mate, tomorrow... I too borrow today. Excuse me mate. Quote Link to comment Share on other sites More sharing options...
russell84 Posted April 9, 2008 Author Share Posted April 9, 2008 Doesn't have to be tomorrow anyways When ever ok - i'm in no rush I have a busy day also - i'm just glad i have this thing working - it drives you crazy when you spend time on something and can't get it to work Cheers and thanks in advance Quote Link to comment Share on other sites More sharing options...
ASMI Posted April 10, 2008 Share Posted April 10, 2008 I hope it will work normally. Please purge "t1" and "t2" drawings, this contains extra "t2" block. LEGEND.LSP Quote Link to comment Share on other sites More sharing options...
russell84 Posted April 10, 2008 Author Share Posted April 10, 2008 That works so much faster! Great Thanks asmi Do you mind telling me what the itoa function in lisp does?? Quote Link to comment Share on other sites More sharing options...
ASMI Posted April 11, 2008 Share Posted April 11, 2008 Do you mind telling me what the itoa function in lisp does?? Sometimes it seems to me you have a special versions of AutoCAD without Help files and disconnect access to Google, Yahoo and to other search systems. Quote Link to comment Share on other sites More sharing options...
russell84 Posted April 11, 2008 Author Share Posted April 11, 2008 Yeah whatever no i have acad civil 3d 3008 - can't find it in the help guide - but yes the net does help - i just thought it might be easier to get someone to tell me instead of reading and searching around because i have limited time thats all. But ok - google it is Have a good weekend mate Thanks heaps for your help - next round is on me Quote Link to comment Share on other sites More sharing options...
russell84 Posted April 11, 2008 Author Share Posted April 11, 2008 ahh it returns a string from a by converting a integer ok makes sense thanks I was just curious thats all Quote Link to comment Share on other sites More sharing options...
MITRA LSP Posted November 19, 2015 Share Posted November 19, 2015 I hope it will work normally. Please purge "t1" and "t2" drawings, this contains extra "t2" block. I would like to try the LEGEND.lsp into my autocad but something gone wrong! "LEGEND.DCL file couldn't be loaded!" I try to insert the LEGEND.txt file that i 've found previously in the same folder of the function but the error remains. Quote Link to comment Share on other sites More sharing options...
ymg3 Posted November 19, 2015 Share Posted November 19, 2015 The lisp is trying to load legend.dcl, means you need to rename legend.txt to legend.dcl You must also make sure that it is in a folder that Acad can reach. ymg Quote Link to comment Share on other sites More sharing options...
ymg3 Posted November 20, 2015 Share Posted November 20, 2015 Mitra, You will also need to create the block you need, one drawing per block named "t1" "t2" . . ."tn" ymg Quote Link to comment Share on other sites More sharing options...
Zac Davis Posted November 27, 2015 Share Posted November 27, 2015 Not Blocks But Great LEGEND lisp Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted November 27, 2015 Share Posted November 27, 2015 Not Blocks But Great LEGEND lisp Zac Davis, If you intend to publish programs on your site which are not your own, it is common coding etiquette to provide a link to the original source of the code, or at least provide some indication that the code is not your own. I wrote the CBRK & CRBKA programs back in 2009 here & here; I also wrote the TBG program in early 2014, found here. XPIPE was written by ASMI back in Feb 2006 and may be found here. Quote Link to comment Share on other sites More sharing options...
Zac Davis Posted November 27, 2015 Share Posted November 27, 2015 (edited) Zac Davis, If you intend to publish programs on your site which are not your own, it is common coding etiquette to provide a link to the original source of the code, or at least provide some indication that the code is not your own. I wrote the CBRK & CRBKA programs back in 2009 here & here; I also wrote the TBG program in early 2014, found here. XPIPE was written by ASMI back in Feb 2006 and may be found here. Hi lee first of all i must thank you for your great codes i use daily from your site. as mentioned in the free lisp page, some codes were found online , i didn't do my research, and i have tons of lisp that i don't know where they come from. happy to hear you wrote CBRK and others. TGB page did mention your name at the top . many other LISP in that this page are very unique and was written in house and you will not be able to find them anywhere else. im really sorry if you feel like i should mention the exact location of the original lisp, but that thing happen naturally if you spread your code for free online. otherwise protection needed. if some codes are yours in the site and you want me to remove them, i will. Edited November 27, 2015 by Zac Davis grammer Quote Link to comment Share on other sites More sharing options...
tombu Posted November 30, 2015 Share Posted November 30, 2015 Hi lee first of all i must thank you for your great codes i use daily from your site. as mentioned in the free lisp page, some codes were found online , i didn't do my research, and i have tons of lisp that i don't know where they come from. happy to hear you wrote CBRK and others. TGB page did mention your name at the top . many other LISP in that this page are very unique and was written in house and you will not be able to find them anywhere else. im really sorry if you feel like i should mention the exact location of the original lisp, but that thing happen naturally if you spread your code for free online. otherwise protection needed. if some codes are yours in the site and you want me to remove them, i will. You've posted a lot of code on your free lisp site without giving any credit to the folk who created it. I use Alan J. Thompson's Break curve At Distance lisp for example. While you at least left his name in the code it's helpful to provide the http://www.theswamp.org/index.php?topic=39550.0;all link as well. The link provides a nice GIF showing how the function works as well as a place to get answers about the code. I keep both author and the link I found it commented in all the code I download as a reference for myself as well as the proper way to share the code with others. If you update your free lisp site to give credit to those who created the code as well as links to where you found the code it would be much more useful to anyone interested in it, besides showing at least the bare minimum of respect for the authors since you didn't get permission to post their efforts as your own. Quote Link to comment Share on other sites More sharing options...
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.