Page 2 of 2 FirstFirst 12
Results 11 to 20 of 20

Thread: Need lisp

  1. #11
    Member
    Join Date
    2009-11
    Posts
    13
    Login to Give a bone
    0

    Default Re: Need lisp

    It doesn't work, get this error:
    ; error: no function definition: M:SAFELIST
    do you know what it means?

  2. #12
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,661
    Login to Give a bone
    0

    Default Re: Need lisp

    Quote Originally Posted by gilmar.pereira View Post
    It doesn't work, get this error:
    ; error: no function definition: M:SAFELIST
    do you know what it means?
    In this case, it just means that Opie's code included a call for a sub-routine (external?).

    Often times someone provides you a snippet of code, which has been culled from a larger routine, and there may be missing, or extra code.

    Opie may be able to provide it to you, or at least tell you what it does, so you can develop your own sub-routine.

    Missing sub-routine:
    Quote Originally Posted by Opie View Post
    Code:
    ...
        (progn
          (setq strData      (strcase (getstring "\nSpecify date: "))
            strNome      (strcase (getstring "\nSpecify username: "))
            strModif      "AS BUILT"
            lstAttributes (m:safelist (vla-getattributes objBlock))
            lstTemp      '()
          )
    ...
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  3. #13
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    8,821
    Login to Give a bone
    0

    Default Re: Need lisp

    m:safelist is shorthand to handle the conversion of a safearray to a list. I also, have it to check for a variant being passed as the argument.
    Code:
    ;_ Convert Safearray to list
    (defun m:safelist (value)
      (if (= (type value) 'VARIANT)
        (setq value (m:variantvalue value))
      )
      (setq value (vl-catch-all-apply 'vlax-safearray->list (list value)))
      (if (vl-catch-all-error-p value)
        nil
        value
      )
    )
    (defun m:variantvalue (value)
      (setq value (vl-catch-all-apply 'vlax-variant-value (list value)))
      (if (vl-catch-all-error-p value)
        nil
        value
      )
    )
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  4. #14
    Member
    Join Date
    2009-11
    Posts
    13
    Login to Give a bone
    0

    Talking Re: Need lisp

    good good job man!!!! It works..
    now I'll improve this lisp to automatically complete name and date

  5. #15
    AUGI Addict
    Join Date
    2008-02
    Posts
    1,141
    Login to Give a bone
    0

    Default Re: Need lisp

    Quote Originally Posted by RenderMan View Post
    In this case, it just means that Opie's code included a call for a sub-routine (external?).

    Often times someone provides you a snippet of code, which has been culled from a larger routine, and there may be missing, or extra code.

    Opie may be able to provide it to you, or at least tell you what it does, so you can develop your own sub-routine.

    Missing sub-routine:
    Quote Originally Posted by Opie View Post
    m:safelist is shorthand to handle the conversion of a safearray to a list. I also, have it to check for a variant being passed as the argument.
    Code:
    ;_ Convert Safearray to list
    (defun m:safelist (value)
      (if (= (type value) 'VARIANT)
        (setq value (m:variantvalue value))
      )
      (setq value (vl-catch-all-apply 'vlax-safearray->list (list value)))
      (if (vl-catch-all-error-p value)
        nil
        value
      )
    )
    (defun m:variantvalue (value)
      (setq value (vl-catch-all-apply 'vlax-variant-value (list value)))
      (if (vl-catch-all-error-p value)
        nil
        value
      )
    )
    FYI
    Code:
    (vlax-invoke objBlock 'GetAttributes)
    Returns attributes in list.

  6. #16
    Member
    Join Date
    2009-11
    Posts
    13
    Login to Give a bone
    0

    Default Re: Need lisp

    I try this in my machine and it works, but when I try in another machine, I get this error:
    Select entity: ; error: bad function: VLAX-ENAME->VLA-OBJECT
    what happens, I tried in autocad mechanical 2009 and 2010

  7. #17
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,661
    Login to Give a bone
    0

    Default Re: Need lisp

    Entere this at the command line:

    Code:
    (vl-load-com)
    Then try Opie's code again... Does it work now?

    If so, then add the code I provided above to ACADDOC.lsp. If not, then please paste what the command line says.

    Hope this helps!
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  8. #18
    Member
    Join Date
    2009-11
    Posts
    13
    Login to Give a bone
    0

    Default Re: Need lisp

    It works, very very thanks...
    This is very useful to me

  9. #19
    Member
    Join Date
    2009-11
    Posts
    13
    Login to Give a bone
    0

    Default Re: Need lisp

    I used it but I can improve this lisp, what can I do to automatically save as path example (c:\as built\) and to automatic save in the revision, example:
    tre drawing is save in c:\041.00_01.00.071_02revA and when I make the revision it goes to revision B, 041.00_01.00.071_02revB, if is it possible to run the lisp and it automatic save the dwg in c:\as built\041.00_01.00.071_02revB

  10. #20
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: Need lisp

    You could do so through calling the saveas command. Although you need to check if the file is overwriting something else, one of 2 ways: use the while-cmdactive idea (see some other threads here); or do a findfile first.

    You get hold of the current drawing's path using (getvar "DWGPREFIX"). The current dwg's name with (getvar "DWGNAME"). Then combine them and any other portions you want using strcat. You may also need to look at the vl-file-directory-p function to check if the as built folder exists or not, and if not then use vl-mkdir.

    You could use the document's activex object's SaveAs method so you don't see anything on the command line - but seeing as you're going to run it in a script I think that's over kill.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 13
    Last Post: 2014-01-20, 06:14 PM
  2. NEED HELP WITH LISP ROUTINE - PURGE linetype lisp
    By ECASAOL350033 in forum AutoLISP
    Replies: 6
    Last Post: 2013-06-21, 01:13 AM
  3. Replies: 3
    Last Post: 2012-05-07, 08:16 PM
  4. Replies: 9
    Last Post: 2012-01-21, 07:58 AM

Posting Permissions

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