Silvercloak Posted April 28, 2015 Posted April 28, 2015 Hi folks, I've been out of the coding scene for a year and half due to moving, new jobs, and basically a hectic life. My new employer found out I know how to code but now I'm rusty as hell and am all but starting over again. Question; I'm trying to create a slips program that will take template layout, create a viewport, pan that viewport window to an individual lot, populate the attributed titleblock with data from an excel sheet, and then create another layout and do it all over again with another address. This may turn out to be a massive project so I'm just going bit by bit. Does anyone know how to have AutoLisp copy a layout and rename it according to a house # or address pulled from an Excel sheet? Silvercloak Quote
BIGAL Posted April 29, 2015 Posted April 29, 2015 I would take a couple of steps back and think about it step by step and create a program for each step individually as defuns this way you can debug one thing at a time. If your lot description is say a text on a layer I would find it and get its insertion point, look at the command "layout" and its options. Forget pan make a viewport and use zoom C pt scale. Do you know how to talk via lisp to excel ? If not GETEXEL.lsp will give you lots of answers, again just do something as a start that reads a certain cell value from excel rather than throwing it straight into the code. Fill in attribute from excel just search here. I know I did colour lots based on excel list of lot numbers it was posted here maybe 1-2 Years ago now. It uses excel to csv maybe be simpler whilst getting everything else working. (defun HATLOT (lotnum col / HATOBJ FPTS PT1 TPT ) (SETQ OLDSNAP (GETVAR "OSMODE")) (SETVAR "OSMODE" 0) (setq lotfound (ssget "X" (LIST (CONS 0 "MTEXT")(CONS 1 lotnum)(CONS 8 "C-BLDG-NMBR")))) (SETQ TPT (ASSOC 10 (ENTGET (ssname lotfound 0)))) (SETQ PT1 (LIST (NTH 1 TPT)(NTH 2 TPT))) (SETQ FPTS (LIST (POLAR PT1 1.57 2 ) PT1)) ; 2 is a dummy value just past text hole (SETQ HATOBJ (ENTGET (SSNAME (SSGET "f" FPTS '((0 . "HATCH"))) 0))) (ENTMOD (subst col (assoc 8 HATOBJ) HATOBJ)) ) ; this is where you would loop through the lots csv from excel number - color ;(while read csv (setq lotnum (getstring "\nEnter lot number")) ; read from file (SETQ COL (cons 8 "60% complete")) ; dummy line for testing make value read from file (HATLOT lotnum perc) ; end while (setvar "osmode" oldsnap) (princ) Quote
Silvercloak Posted April 29, 2015 Author Posted April 29, 2015 I would take a couple of steps back and think about it step by step and create a program for each step individually as defuns this way you can debug one thing at a time. If your lot description is say a text on a layer I would find it and get its insertion point, look at the command "layout" and its options. Forget pan make a viewport and use zoom C pt scale. Do you know how to talk via lisp to excel ? If not GETEXEL.lsp will give you lots of answers, again just do something as a start that reads a certain cell value from excel rather than throwing it straight into the code. Fill in attribute from excel just search here. I know I did colour lots based on excel list of lot numbers it was posted here maybe 1-2 Years ago now. It uses excel to csv maybe be simpler whilst getting everything else working. (defun HATLOT (lotnum col / HATOBJ FPTS PT1 TPT ) (SETQ OLDSNAP (GETVAR "OSMODE")) (SETVAR "OSMODE" 0) (setq lotfound (ssget "X" (LIST (CONS 0 "MTEXT")(CONS 1 lotnum)(CONS 8 "C-BLDG-NMBR")))) (SETQ TPT (ASSOC 10 (ENTGET (ssname lotfound 0)))) (SETQ PT1 (LIST (NTH 1 TPT)(NTH 2 TPT))) (SETQ FPTS (LIST (POLAR PT1 1.57 2 ) PT1)) ; 2 is a dummy value just past text hole (SETQ HATOBJ (ENTGET (SSNAME (SSGET "f" FPTS '((0 . "HATCH"))) 0))) (ENTMOD (subst col (assoc 8 HATOBJ) HATOBJ)) ) ; this is where you would loop through the lots csv from excel number - color ;(while read csv (setq lotnum (getstring "\nEnter lot number")) ; read from file (SETQ COL (cons 8 "60% complete")) ; dummy line for testing make value read from file (HATLOT lotnum perc) ; end while (setvar "osmode" oldsnap) (princ) Thanks - that's pretty much how I'm going about it too. I'm just curious if anyone knows of any layout commands that would work in LISP. Anyways, I'm just brushing up and trying to get back into a coding mindset by going through a tutorial and doing the exercises again. Silvercloak Quote
Silvercloak Posted April 30, 2015 Author Posted April 30, 2015 (command "Layout") ? Pretty much all I can think of.... I haven't learned DCL yet either. Quote
BIGAL Posted May 1, 2015 Posted May 1, 2015 Did you try (command "Layout" "new" (setq lname (getstring))) ; or copy (setvar "ctab" lname) ; insert title block ; mview ; ms ; z c pt ; hey all done Quote
SanMiguel Posted May 4, 2015 Posted May 4, 2015 similar problem I have inserting a template title block in a new dwg using this script: filedia 0 _layout _template ftth_tblock.dwt filedia 1 the script stops at _template, autocad says unknown command at _template... please help.... Quote
BIGAL Posted May 5, 2015 Posted May 5, 2015 SanMiguel if you look at the options for layout like NEW TEMPLATE COPY no _ In a different language will need to look at Layout then options in the correct language maybe. Quote
SanMiguel Posted May 5, 2015 Posted May 5, 2015 hi Bigal, I figured out a work around with my script it goes a little something like this: _layout _template ftth_tblock1 layout1 Thanks! 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.