See the top rated post in this thread. Click here

Results 1 to 7 of 7

Thread: Updating a simple lisp routine to Autocad 2014

  1. #1
    Member
    Join Date
    2011-12
    Posts
    13
    Login to Give a bone
    0

    Default Updating a simple lisp routine to Autocad 2014

    Hello everyone.
    Happy new year .

    So, my problem goes like this:

    We've been using a lisp routine to draw pipes since 2010, and it has been very useful mainly to extract quantities (with the "ExtAttr.xls" file that comes with Autocad). However, we want to update to Autocad 2014, and the routine doesn´t work in it.

    I think I managed to trace back the problem to a "tracewid" variable, that became obsolete in Autocad 2012. The thing is, I don't really know that much lisp, so I'm not really sure how to fix it, or even if it should be fixed in the first place - maybe I could try to write a routine from scratch, that lets me draw pipes and extract its quantities, but currently I don´t even know where to start .

    Any help or insight you can give me is extremely appreciated.

    This is the routine:
    Code:
    ;TUBOS STANDARD
    (defun C:tubo ()
      (SETVAR "cmdecho" 0)
      (setq sx 0.0)
      (setq os (getvar "osmode"))
      (setvar "osmode" 247) 
      (setq pi (getpoint "\nPunto de Inicio : "))
      (setq pf (getpoint "\nPunto final : " pi))
      (setvar "osmode" 0) 
      (setq ang1 (/ (angle pi pf) 0.0174533))
      (setq ang2 (/ (angle pf pi) 0.0174533))  
      (setq pi1 (car pi))
      (setq pi2 (cadr pi))
      (setq sx (distance pi pf))
      (setq sxd (rtos sx 2 2))
      (setq sy (getvar "tracewid"))
      (setq dt (/ (distance pi pf) 2))
      (setq p1t (polar pi ang1 dt))
      (command "insert" "tb" (list pi1 pi2) sx sy ang1 mat sxd)
      (setvar "osmode" os)
      )
    This is an example of the script we use to draw the pipes:
    Code:
    ^c^csetvar tracewid 0.083 (setq mat "PVC-S TUB. 3") (setq dia 3) tubo
    I also attached the block file needed for the routine (although, I'm not sure how it works. If anyone would care to explain, i'd be very grateful)

    Thanks for your time.
    Attached Files Attached Files

  2. #2
    I could stop if I wanted to
    Join Date
    2005-06
    Location
    CORDOBA-ARGENTINA
    Posts
    275
    Login to Give a bone
    1

    Default Re: Updating a simple lisp routine to Autocad 2014

    Hola Dano . la variable de sistema "tracewid" está activa en 2013 , luego ese no es el problema

    Command: (getvar "tracewid")
    1.0


    Command: (getvar 'tracewid)
    1.0

    Command: (setvar 'tracewid 2)
    2

    Command: (getvar 'tracewid)
    2.0

  3. #3
    Member
    Join Date
    2013-02
    Posts
    34
    Login to Give a bone
    1

    Default Re: Updating a simple lisp routine to Autocad 2014

    Dear Danoposada,

    Your LISP routine has error. You have used variable pi for Initial Point which is incorrect because pi is inbuilt function in LISP which has value 3.14159.....
    Hence, I have changed the variable name to pinit and changed it further in the LISP. Modified LISP file is as follows :-

    Code:
    ;TUBOS STANDARD
    (defun C:tubo ()
      (SETVAR "cmdecho" 0)
      (setq sx 0.0)
      (setq os (getvar "osmode"))
      (setvar "osmode" 247)
      (setq pinit (getpoint "\nPunto de Inicio : "))
      (setq pf (getpoint "\nPunto final : " pinit))
      (setvar "osmode" 0)
      (setq ang1 (/ (angle pinit pf) 0.0174533))
      (setq ang2 (/ (angle pf pinit) 0.0174533))
      (setq pi1 (car pinit))
      (setq pi2 (cadr pinit))
      (setq sx (distance pinit pf))
      (setq sxd (rtos sx 2 2))
      (setq sy (getvar "tracewid"))
      (setq dt (/ (distance pinit pf) 2))
      (setq p1t (polar pinit ang1 dt))
      (command "insert" "tb" (list pi1 pi2) sx sy ang1 mat sxd)
      (setvar "osmode" os)
    )
    Also, kindly modify your script as follows :-

    Code:
    (setvar 'tracewid 0.083) (setq mat "PVC-S TUB. 3") (setq dia 3) tubo

    I have done these changes and it works fine for me.
    Kindly check at your end and tell.

    Also, where are you using variable "dia" given in your Script ? "dia" is not being used in LISP anywhere.
    Last edited by mailmaverick361505; 2013-12-28 at 11:17 AM.

  4. #4
    I could stop if I wanted to
    Join Date
    2005-06
    Location
    CORDOBA-ARGENTINA
    Posts
    275
    Login to Give a bone
    0

    Default Re: Updating a simple lisp routine to Autocad 2014

    Hi Maverick, please tell me where the (setq dia 3) apply at the LISP.
    Last edited by devitg.89838; 2013-12-28 at 11:50 AM.

  5. #5
    Member
    Join Date
    2013-02
    Posts
    34
    Login to Give a bone
    1

    Default Re: Updating a simple lisp routine to Autocad 2014

    Dear Danoposada,

    (setq dia 3) is not being used anywhere in LISP.

    Where to use it, I don't know.

    That depends upon your logic.

  6. #6
    I could stop if I wanted to
    Join Date
    2005-06
    Location
    CORDOBA-ARGENTINA
    Posts
    275
    Login to Give a bone
    0

    Default Re: Updating a simple lisp routine to Autocad 2014

    Maverick , please apologize me , I did not notice it was at the OP post

  7. #7
    Member
    Join Date
    2011-12
    Posts
    13
    Login to Give a bone
    0

    Default Re: Updating a simple lisp routine to Autocad 2014

    Truth be told, I've no idea what the "(setq dia 3)" part does. I thought it had something to do with quantities extraction, but I just noticed that the 3" pipes were the only ones that had it.

    Maybe it's part of an old code?

    Anyway, I have to thank Maverick big time: the code worked, and quantity extraction is also working. The only problem I found is that, with the new script, the tool properties overrides do not work (color, layer, linetype) and act as if they were set as "--use current". The moment I add the extra parenthesis, the overrides stop working. Is that normal? I can even break the overrides of the old code by just adding them, e.g:
    ^c^csetvar (tracewid) 0.083 (setq mat "PVC-S TUB. 3") (setq dia 3) tubo.
    As you see, the only thing I need to replicate the problem is to encase the "tracewid" part in parenthesis.

    Maybe I should add the desired overrides directly from the script? or should I try to find a way to make the overrides work?

    In any case, the most important part is fixed: thank you Maverick, this helped me Big Time.

    EDIT: And I found out how to get the overrides working again ^_^.
    Last edited by Danoposada320107; 2014-01-07 at 03:22 PM.

Similar Threads

  1. Replies: 1
    Last Post: 2014-04-15, 06:15 PM
  2. Doing simple string manipulation with LISP in Autocad
    By j7linz438475 in forum AutoLISP
    Replies: 2
    Last Post: 2013-11-05, 10:43 PM
  3. Replies: 4
    Last Post: 2013-06-21, 09:46 PM
  4. Replies: 4
    Last Post: 2008-09-06, 08:10 PM
  5. Request for a simple lisp routine
    By BM75 in forum AutoLISP
    Replies: 5
    Last Post: 2005-11-23, 10:27 PM

Posting Permissions

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