+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Forum Newbie
    Using
    Civil 3D 2011
    Join Date
    May 2010
    Posts
    9

    AutoCAD Beginner Question

    Registered forum members do not see this ad.

    Hello everyone,

    Well, as a result of AlanJT's gentle encouragement, I am diving into the world of writing my own lisp routines. As a start, I've read (and partially understood) the LISP tutorial posted on this website. I have a couple of quick newbie questions:

    1. Should you be cutting and pasting the lisp routines that you intend to use into the Acad20xx.doc file so that they load up every time you start a new drawing or should you be loading up each one on an individual basis?

    2. And if it is the latter... can you group all the routines together into one big lisp file so you only have to load it up once?

    3. I have read the tutorial but I am still a bit fuzzy on when to use:

    (defun drawline (/ pntl pnt2)

    as opposed to:

    (defun C:drawline (/ pntl pnt2)

    4. Should a lisp that runs in 2008 run in AutoCAD 2010 and 2011?

    Any help would be appreciated... and I apologize now if I am posting this in the wrong forum.

    M

  2. #2
    Forum Deity
    Using
    AutoCAD 2009
    Join Date
    Oct 2008
    Posts
    2,112

    Default

    Quote Originally Posted by Mezalaja View Post
    Hello everyone,

    Well, as a result of AlanJT's gentle encouragement, I am diving into the world of writing my own lisp routines. As a start, I've read (and partially understood) the LISP tutorial posted on this website. I have a couple of quick newbie questions:

    1. Should you be cutting and pasting the lisp routines that you intend to use into the Acad20xx.doc file so that they load up every time you start a new drawing or should you be loading up each one on an individual basis?

    2. And if it is the latter... can you group all the routines together into one big lisp file so you only have to load it up once?

    3. I have read the tutorial but I am still a bit fuzzy on when to use:

    (defun drawline (/ pntl pnt2)

    as opposed to:

    (defun C:drawline (/ pntl pnt2)

    4. Should a lisp that runs in 2008 run in AutoCAD 2010 and 2011?

    Any help would be appreciated... and I apologize now if I am posting this in the wrong forum.

    M
    You should not edit the Acad20xx.lsp at all. Do not get this confused with the ACADDOC.lsp
    Those are two different files. You will want to create a ACADDOC.lsp

  3. #3
    Senior Member
    Computer Details
    Glen Smith's Computer Details
    Operating System:
    Win XP
    Computer:
    Dell Studio XPS 1645
    CPU:
    Intel i7 Q720 @ 1.6Ghz
    RAM:
    8 Gig
    Using
    Electrical 2010
    Join Date
    May 2008
    Location
    Cary, NC
    Posts
    418

    Default

    Well, I'm not much farther along than you, but I think I can answer your questions.

    1. Best practice is not to use the ACAD20??.lsp file as this technically belongs to ACAD and they can overwrite it at will, besides the fact that every time you get a new version you have to migrate last years to this years. Lots of people do use the ACADyear file though.

    The ACADDOC.LSP file is dedicated to the user and should not be overwritten and stays the same regardless of what version you are using.

    2. Yes you can append multiple LISPs into the ACADDOC.lsp file (once you have them working!) and CAD will load them every time you open a new drawing.

    3. LISP's are generally forward compatible. New commands occasionally get added, so if you use a 2010 command that isn't available in 2008, the LISP will have problems with backward compatability.

    4. I THINK that the difference is that the defun C: allows the function to be called from CAD at the command line. defun ... functions are only callable from within the LISP that they are defined in.

    Good luck getting better acquainted with LISP, and welcome to the forum.

    Glen
    “Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something." Lazarus Long in Time Enough For Love

  4. #4
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    4,008

    Default

    Quote Originally Posted by Mezalaja View Post
    4. Should a lisp that runs in 2008 run in AutoCAD 2010 and 2011?
    To avoid compatibility issues it is recommended to build entities by their associated lists instead of using COMMAND statement.

    Regarding the backward compatibility, both lines of code below are working (the prompts of TEXT command changed over time):

    Code:
    (command "_TEXT" "_J" "_MC" '(0.0 0.0) 5.0 0 "Hello World!")
    (command "_TEXT" "_MC" '(0.0 0.0) 5.0 0 "Hello World!")
    And this is the associated list approach:

    Code:
    (entmake (list '(0 . "TEXT")
                   (cons '10 '(0.0 0.0 0.0))
                   (cons '11 '(0.0 0.0 0.0))
                   (cons '1 "Hello World!")
                   '(40 . 5.0)
                   '(72 . 1)
                   '(73 . 2)))
    Regards,
    Last edited by MSasu; 1st Jul 2010 at 06:20 am.

  5. #5
    Super Member fixo's Avatar
    Computer Details
    fixo's Computer Details
    Operating System:
    Windows 7
    Motherboard:
    E7500
    CPU:
    Intel(R)Core(TM)2 DUO CPU 2.93HGz
    RAM:
    4098 Gb
    Graphics:
    1024 Gb
    Using
    AutoCAD 2009
    Join Date
    Jul 2005
    Location
    Thanks God, I'm far enough from Hitleropa
    Posts
    1,697

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by msasu View Post
    To avoid compatibility issues it is recommended to build entities by their associated lists instead of using COMMAND statement.

    Regarding the backward compatibility, both lines of code below are working (the prompts of TEXT command changed over time):

    Code:
    (command "_TEXT" "_J" "_MC" '(0.0 0.0) 5.0 0 "Hello World!")
    (command "_TEXT" "_MC" '(0.0 0.0) 5.0 0 "Hello World!")
    And this is the associated list approach:

    Code:
    (entmake (list '(0 . "TEXT")
                   (cons '10 '(0.0 0.0 0.0))
                   (cons '11 '(0.0 0.0 0.0))
                   (cons '1 "Hello World!")
                   '(40 . 5.0)
                   '(72 . 1)
                   '(73 . 2)))
    Regards,
    The best way is to write function with changeable parameters IMHO
    Something like this handy
    (You can write the similar on it for entmakeing)
    Code:
    ;;author unknown 
      (defun text-draw (txt pnt height rotation justification)
       (if (null pnt)(command "_.-TEXT" "" txt)
       (if (= (cdr (assoc 40 (tblsearch "STYLE" (getvar "TEXTSTYLE"))))
        0.0
           ) 
         (progn     
           (if justification
       (command "_.-TEXT" "_J" justification "_none" pnt height rotation txt)
       (command "_.-TEXT" "_none" pnt height rotation txt)
           ) 
         ) 
         (progn
           (if justification
       (command "_.-TEXT" "_J" justification "_none" pnt rotation txt)
       (command "_.-TEXT" "_none" pnt rotation txt)
           ) 
         ) 
       ) 
         )
      (entlast)
    )
    ~'J'~
    The soul is healed by being with children. - Fyodor Dostoyevsky, novelist (1821-1881)

Similar Threads

  1. Beginner question
    By Lt Dan's legs in forum AutoLISP, Visual LISP & DCL
    Replies: 28
    Last Post: 17th Jun 2010, 07:18 pm
  2. super beginner question-steps
    By richie_008 in forum AutoCAD Beginners' Area
    Replies: 10
    Last Post: 24th Feb 2009, 11:37 pm
  3. CSS for the beginner ?
    By David de Botton in forum Web Design
    Replies: 6
    Last Post: 6th Nov 2006, 10:21 am
  4. beginner
    By manyos in forum AutoCAD Beginners' Area
    Replies: 5
    Last Post: 18th Feb 2006, 08:16 pm
  5. Beginner with LSP
    By wilbee in forum AutoLISP, Visual LISP & DCL
    Replies: 5
    Last Post: 17th Jan 2005, 01:52 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts