+ Reply to Thread
Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 22
  1. #1
    Junior Member
    Using
    AutoCAD 2008
    Join Date
    Aug 2012
    Posts
    21

    Default run lisp in lisp???

    Registered forum members do not see this ad.

    Good morning,
    Let's say i have a lisp that will erase all points in a drawing. This is a general question, maybe there is a general solution, i don't know... My lisp works ok, but in my drawing i have some blocks - and these blocks have points inside. How can i use a lisp inside of each block in a drawing? I mean, is it possible to have a lisp that will run another lisp (already made) inside of each block in a drawing?
    Last edited by manase; 29th Aug 2012 at 08:17 am.

  2. #2
    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
    2,998

    Default

    Welcome to the Forum, Manase.

    Seems to me that you are referring to two different matters. (1) To run an existing AutoLISP routine from your code just do, if defined as function:
    Code:
    (MyALispFunction)
    respectively if defined as command:
    Code:
    (C:MyALispCommand)

    (2) To apply the editing inside blocks, you will need to parse the entities that compose that block’s definition. Seems that your routine will require some re-work.
    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

  3. #3
    Super Member irneb's Avatar
    Computer Details
    irneb's Computer Details
    Operating System:
    Win7 Pro 64bit
    Computer:
    Antec One Hundred
    Motherboard:
    ASUS P8P67-Pro P67
    CPU:
    Intel i7 2600 @ 3.4GHz
    RAM:
    16GB-1600MHz
    Graphics:
    GeForce GT 430 (1GB)
    Primary Storage:
    Seagate1TB SATA2 - 7200rpm
    Monitor:
    Samsung 2333TN 23" 1920 x 1080 Full HD LCD Monitor2GW
    Discipline
    Architectural
    irneb's Discipline Details
    Occupation
    Architectural Technician and Programmer
    Discipline
    Architectural
    Using
    AutoCAD 2013
    Join Date
    Sep 2010
    Location
    Jo'burg SA
    Posts
    1,634

    Default

    You might try creating a command function which steps through all blocks using the tblnext function. Then check for stuff (from the data returned by tblnext) like is it an xref / unnamed (i.e. dynamic block placeholder), if not start the BEdit command run the existing (c:CommandName) use BSave/BClose and loop to the next block. This is probably going to run very slow though, perhaps MSasu's second point may make it a lot faster.

    Could you perhaps post the code so we can see what it does? Otherwise we can't give you a definitive answer.
    Knowledge is proportional to experience, but wisdom is inversely proportional to ego!
    My little bit of "wisdom": Hind-sight is useless, unless used to improve the next forethought!

  4. #4
    Junior Member
    Using
    AutoCAD 2008
    Join Date
    Aug 2012
    Posts
    21

    Default

    As i said, this is a general question, and i want a general solution - i mean, to have a lisp that will use another lisp already made, using MSasu solution,
    Code:
    (C:MyALispCommand)
    Code:
      (defun c:points ( / )
        (setq p (ssget "_x"(list '(0 . "POINT"))))
        (command "erase" p "" )
        )
    This is a basic example - i want to erase all points in a drawing, including points that are inside of blocks (and nested blocks). For me, the best solution is a lisp that will use another lisp (already made) inside of Bedit
    command (with tblnext function). If will run slow, is not a problem - only few blocks and nested blocks in my drawings.

  5. #5
    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
    2,998

    Default

    A workaround based on your proposed solution:
    Code:
    ; Kill Points in Blocks routine (29-VIII-2012)
    (defun c:KPB( / blockItem ssetPoints )
     (while (setq blockItem (tblnext "BLOCK" (not blockItem)))
      (command "_BEDIT" (cdr (assoc 2 blockItem)))
      (if (setq ssetPoints (ssget "_X" '((0 . "POINT"))))
       (command "_ERASE" ssetPoints ""
                "_BCLOSE" "_S")
       (command "_BCLOSE")
      )
     )
     (princ)
    )
    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

  6. #6
    Super Member irneb's Avatar
    Computer Details
    irneb's Computer Details
    Operating System:
    Win7 Pro 64bit
    Computer:
    Antec One Hundred
    Motherboard:
    ASUS P8P67-Pro P67
    CPU:
    Intel i7 2600 @ 3.4GHz
    RAM:
    16GB-1600MHz
    Graphics:
    GeForce GT 430 (1GB)
    Primary Storage:
    Seagate1TB SATA2 - 7200rpm
    Monitor:
    Samsung 2333TN 23" 1920 x 1080 Full HD LCD Monitor2GW
    Discipline
    Architectural
    irneb's Discipline Details
    Occupation
    Architectural Technician and Programmer
    Discipline
    Architectural
    Using
    AutoCAD 2013
    Join Date
    Sep 2010
    Location
    Jo'burg SA
    Posts
    1,634

    Default

    Something like this then
    Code:
    (defun c:points ( / p)
      (if (setq p (ssget "_x"(list '(0 . "POINT"))))
        (command "erase" p "" ))
      (princ))
    
    (defun c:points2 (/ blk)
      (while (setq blk (tblnext "BLOCK" (not blk)))
        (if (= (logand (cdr (assoc 70 blk)) (+ 1 4 8 16 32 64)) 0) ;Check for not unnamed / xref
          (progn (command "._BEDIT" (cdr (assoc 2 blk)))
            (c:points) ;Call other lisp routine
            (command "._BSAVE" "._BCLOSE"))))
      (princ))
    Knowledge is proportional to experience, but wisdom is inversely proportional to ego!
    My little bit of "wisdom": Hind-sight is useless, unless used to improve the next forethought!

  7. #7
    Junior Member
    Using
    AutoCAD 2008
    Join Date
    Aug 2012
    Posts
    21

    Default

    In this case, your solution is ok, but is not a general solution. I want to use my lisp "points" defined above, not to make a new selection of points...etc... - you don't use a lisp defined already. - this answer is for MSasu

  8. #8
    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
    2,998

    Default

    To use the said POINTS user defined command will need to adjust it a little to return if there were points removed or not - since this will affect the way BCLOSE built-in command works.
    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

  9. #9
    Super Member irneb's Avatar
    Computer Details
    irneb's Computer Details
    Operating System:
    Win7 Pro 64bit
    Computer:
    Antec One Hundred
    Motherboard:
    ASUS P8P67-Pro P67
    CPU:
    Intel i7 2600 @ 3.4GHz
    RAM:
    16GB-1600MHz
    Graphics:
    GeForce GT 430 (1GB)
    Primary Storage:
    Seagate1TB SATA2 - 7200rpm
    Monitor:
    Samsung 2333TN 23" 1920 x 1080 Full HD LCD Monitor2GW
    Discipline
    Architectural
    irneb's Discipline Details
    Occupation
    Architectural Technician and Programmer
    Discipline
    Architectural
    Using
    AutoCAD 2013
    Join Date
    Sep 2010
    Location
    Jo'burg SA
    Posts
    1,634

    Default

    Quote Originally Posted by manase View Post
    In this case, your solution is ok, but is not a general solution. I want to use my lisp "points" defined above, not to make a new selection of points...etc... - you don't use a lisp defined already. - this answer is for MSasu
    Note that this is rather specific - not actually a "generalized" thing. In this case you're fortunate since the points command can operate inside the BEdit environment and doesn't ask for any user input - else the code in my previous post wouldn't have worked fully.

    Quote Originally Posted by MSasu View Post
    To use the said POINTS user defined command will need to adjust it a little to return if there were points removed or not - since this will affect the way BCLOSE built-in command works.
    That's why I'm using the BSave before the BClose. That way BClose works the same no matter if something's changed or not.
    Knowledge is proportional to experience, but wisdom is inversely proportional to ego!
    My little bit of "wisdom": Hind-sight is useless, unless used to improve the next forethought!

  10. #10
    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
    2,998

    Default

    Registered forum members do not see this ad.

    Please try this then:
    Code:
    (defun c:points( / p )
     (if (setq p (ssget "_x" (list '(0 . "POINT"))))
      (command "erase" p "")
      T
     )
    )
    ; Kill Points in Blocks routine (29-VIII-2012)
    (defun c:KPB( / blockItem )
     (while (setq blockItem (tblnext "BLOCK" (not blockItem)))
      (command "_BEDIT" (cdr (assoc 2 blockItem)))
      (if (C:POINTS)
       (command "_BCLOSE")
       (command "_BCLOSE" "_S")
      )
     )
     (princ)
    )
    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

Similar Threads

  1. Lisp to show in what routine you are in, in a big lisp program.
    By ctdlc888 in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 21st Mar 2012, 02:31 am
  2. chk my new lisp & suggestion how to improve this lisp (intersecation cleane)
    By autolisp in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 1st Sep 2010, 03:55 am
  3. Replies: 3
    Last Post: 10th Aug 2010, 04:39 am
  4. a lisp to apply 3 different lisp to 3 obj types filtered from one selection
    By gilsoto13 in forum AutoLISP, Visual LISP & DCL
    Replies: 28
    Last Post: 5th Nov 2009, 05:28 am
  5. problem, trying to running a list of lisp from within a lisp
    By twind2000 in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 20th Aug 2007, 04: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