+ Reply to Thread
Page 2 of 3 FirstFirst 1 2 3 LastLast
Results 11 to 20 of 23
  1. #11
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,727

    Default

    Registered forum members do not see this ad.

    An old FAQ I wrote a while back...

    http://www.cadtutor.net/forum/showpo...49&postcount=4
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  2. #12
    Forum Deity Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draftsman
    Discipline
    Mechanical
    Using
    AutoCAD 2014
    Join Date
    Oct 2009
    Location
    Lives in Abu Dhabi
    Posts
    2,627

    Default

    Quote Originally Posted by VVA View Post
    names after / - local variables. The time of their lives - body functions (commands) to which they are defined
    small example
    Code:
    (defun C:TEST1 ( )
      ;;;str - a global variable. It retains its value after the command
      (setq str (getstring "\nType any word: "))
      (princ "\nYou enter ")(princ str)
      (princ)
      )
    
    (defun C:TEST2 (/ str1 )
      ;;;str1 - a local variable. It is removed after the completion of command
      (setq str1 (getstring "\nType any word: "))
      (princ "\nYou enter ")(princ str1)
      (princ)
      )
    And Result
    really nice explanation , And I haven't known that way before.

    But what about this function
    (defun abc (o p q r / v w x y z)
    Does it mean that they have to be supported with values before implementing
    the defun function

    Thanks
    Tharwat

  3. #13
    Senior Member ksperopoulos's Avatar
    Computer Details
    ksperopoulos's Computer Details
    Operating System:
    Windows 7; 64-bit
    Computer:
    HP Elitebook 8760w
    RAM:
    16GB
    Graphics:
    NVIDIA Quadro 4000M
    Using
    AutoCAD 2013
    Join Date
    Feb 2009
    Location
    Overland Park, KS
    Posts
    135

    Default

    Thanks for the explanation VVA. So these would be needed if I were to include them in another lisp without the defun name to carry the variable through that command.

  4. #14
    Forum Newbie
    Using
    AutoCAD 2010
    Join Date
    Dec 2011
    Posts
    3

    Default Not working

    The code does not work on paper view

  5. #15
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,106

    Default

    Because it invokes a call to command function. it only "erase" objects on the current layout.

    Quick mod:
    Code:
    (defun C:edims (/ ss)
      (if (setq ss (ssget "_x" (list (cons 0 "*DIMENSION"))))
           (repeat (sslength ss)
                  (entdel (ssname ss 0))
                  (ssdel (ssname ss 0) ss))
            )
      (princ)
       )

  6. #16
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,727

    Default

    Another:

    Code:
    (defun c:deldims ( / d )
        (vlax-for b (vla-get-blocks (setq d (vla-get-activedocument (vlax-get-acad-object))))
            (if (eq :vlax-false (vla-get-isxref b))
                (vlax-for o b
                    (if (wcmatch (vla-get-objectname o) "AcDb*Dimension*")
                        (vl-catch-all-apply 'vla-delete (list o))
                    )
                )
            )
        )
        (vla-regen d acallviewports)
        (princ)
    )
    (vl-load-com) (princ)
    Will delete all Dimension types found in all layouts and in all blocks and nested blocks.

    Will omit Dimensions in XRefs and on locked layers.
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  7. #17
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,106

    Default

    Quote Originally Posted by Lee Mac View Post

    Code:
    (vl-catch-all-apply 'vla-delete (list o))
    .....and on locked layers.
    Clever, I wonder why vla-** behaves that way, (i mean errors) when encountering locked layers as compared to entdel/entmod thingy which ( appears to) breeze thru them as if nothing happens... ?

  8. #18
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,727

    Default

    Quote Originally Posted by pBe View Post
    I wonder why vla-** behaves that way, (i mean errors) when encountering locked layers as compared to entdel/entmod thingy which ( appears to) breeze thru them as if nothing happens... ?
    entdel / entmod will still fail to delete / modify entities on locked layers, however, when these functions fail they return nil rather than error. When Visual LISP functions fail, they cause an exception to occur.

    Compare the behaviour of:

    Code:
    AutoLISP                 Visual LISP
    ------------------------------------------
    entdel                   vla-delete
    entmod                   vlax-put-property
    tblsearch / dictsearch   vla-item
    etc.
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  9. #19
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,106

    Default

    Quote Originally Posted by Lee Mac View Post
    ....rather than error. When Visual LISP functions fail, they cause an exception to occur.
    Got it. Thanks Lee

    Cheers

  10. #20
    Forum Newbie
    Using
    AutoCAD 2010
    Join Date
    Dec 2011
    Posts
    3

    Default

    Registered forum members do not see this ad.

    You can apply it with locked layers?

Similar Threads

  1. Delete Key...
    By GOHO in forum AutoCAD Beginners' Area
    Replies: 12
    Last Post: 21st Mar 2010, 01:15 am
  2. I can't delete lines using the delete button!!
    By lofty in forum AutoCAD General
    Replies: 6
    Last Post: 10th Dec 2009, 07:36 pm
  3. I can't delete line using delete and backspace keys
    By alif in forum AutoCAD Beginners' Area
    Replies: 1
    Last Post: 21st Apr 2009, 03:42 am
  4. Delete layers that wont delete
    By seashell2day in forum AutoCAD General
    Replies: 5
    Last Post: 31st Mar 2009, 02:38 pm
  5. Delete key
    By steve @ mp in forum AutoCAD Drawing Management & Output
    Replies: 13
    Last Post: 5th Feb 2009, 11:27 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