Results 1 to 8 of 8

Thread: I'm close, but not quite there yet...

  1. #1
    Active Member
    Join Date
    2008-06
    Location
    Rochester, NY
    Posts
    94

    Default I'm close, but not quite there yet...

    Thank you to forums like these I've been picking up (or at least trying) this Lisp stuff. It's been a big help.

    I am trying to write a script for AutoCAD to clean up some Exported models from Revit. i am trying to get the script to add a new G-ANNO-VPRT layer, put all viewports on that layer, take all block references in model space that have a name that starts with 803000... and move them to the back, then explode them, the script will also force all colors of all objects to ByLayer in model and paper space, then it will remove all text masking and zoom extent, purge, audit, and save.

    I have a script that runs a few lisps, and I'm very close. I am getting hung up on selecting all the block references in modelspace that starts with 803000... to send them to back and explode them. The current lines I have for that only are selecting one of the block references in the file, it will eventually select the other one, but it has to be run an additional 2-3 times for it to be included, I have no idea why.

    I have attached my script and the lisp files it runs if you'd like to take a look.

    Thank you.
    Attached Files Attached Files

  2. #2
    AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL
    Posts
    1,098

    Default Re: I'm close, but not quite there yet...

    When you explode each of those blocks you are replacing a reference to a block definition with a new group of objects. The easiest way to do what you want is to (setq EN (entlast)) before exploding the blocks. Then everything after EN will be the newly created objects from the exploded block references. (entnext EN) will give you the first one. You will need to create a selection set of all the new objects to modify their color & draw order. As the newest objects in the drawing they will be on top regardless where the block references were.

    Gotta run if you still need help creating the selection set I'll reply with some code tomorrow.
    Tom Beauford P.S.M. - Civil 2013 on Windows 7 Pro
    Design Analysis - Leon County Public Works/Engineering
    2280 Miccosukee Rd. Tallahassee, FL 32308-5310
    Ph# (850)606-1516

  3. #3
    I could stop if I wanted to marko_ribar's Avatar
    Join Date
    2004-06
    Location
    Belgrade, Serbia, Europe
    Posts
    414

    Default Re: I'm close, but not quite there yet...

    When you explode block, you can get newly created entities with (ssget "_P")... Only thing you should consider is that you must explode each block with (command "_.explode" bname) where bname is (tblobjname "BLOCK" "blname")... Note that you shouldn't use (vla-Explode bl-vlaobj) as after that you can't get subentites selection with (ssget "_P")...

    M.R.
    Marko Ribar, d.i.a. (graduated engineer of architecture)

    M.R. on Youtube


  4. #4
    Active Member
    Join Date
    2008-06
    Location
    Rochester, NY
    Posts
    94

    Default Re: I'm close, but not quite there yet...

    Thank you for the quick responses Tom and Marko!
    I will look at (setq EN (entlast)) and (entnext EN) a little bit more, as I am not familiar with them yet.
    Correct me if I'm wrong, but both of your solutions sound like they are trying to help me select the objects after they are exploded. My problem may be a little bit simpler. I am having problems exploding the blocks. If I just paste the one line of my lisp into the AutoCAD command line:

    (command "._EXPLODE" (ssget "_X" '((0 . "INSERT" ) (2 . "803000*") (410 . "Model"))) )

    it will only select 1 of 2 block references with a name that starts with 803000 and explode it. I don't know why it's not exploding all the blocks. I may be missing something that you guys are trying to tell me, if so, i am sorry.

    Thank you.

  5. #5
    AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL
    Posts
    1,098

    Default Re: I'm close, but not quite there yet...

    Try this:
    Code:
     (defun c:xrefexplode ( / lastent flag ss)
      (setq lastent (entlast)
            flag (getvar "qaflags")
      (setq ss (ssget "_X" '((0 . "INSERT" ) (2 . "803000*") (410 . "Model"))))
      (setvar "qaflags" 1) 
      (command "._EXPLODE" ss "")
      (setvar "qaflags" flag) 
      (setq ss (ssadd))
      (while (entnext lastent)
       (setq lastent (entnext lastent))
       (ssadd lastent ss)
      )
      (command "._DRAWORDER" ss "" "b" )
      (princ)
    )
    Tom Beauford P.S.M. - Civil 2013 on Windows 7 Pro
    Design Analysis - Leon County Public Works/Engineering
    2280 Miccosukee Rd. Tallahassee, FL 32308-5310
    Ph# (850)606-1516

  6. #6
    Active Member
    Join Date
    2008-06
    Location
    Rochester, NY
    Posts
    94

    Default Re: I'm close, but not quite there yet...

    Thank you again Tom!! I'll give it a try.

  7. #7
    Active Member
    Join Date
    2008-06
    Location
    Rochester, NY
    Posts
    94

    Default Re: I'm close, but not quite there yet...

    Tom, Thank you very much, this is perfect (other than there was a missing parenthesis, but I found it). I am looking forward to researching this lisp more in depth to find out what each of these lines do. Thanks again!!

  8. #8
    AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL
    Posts
    1,098

    Default Re: I'm close, but not quite there yet...

    Quote Originally Posted by dwahl View Post
    Tom, Thank you very much, this is perfect (other than there was a missing parenthesis, but I found it). I am looking forward to researching this lisp more in depth to find out what each of these lines do. Thanks again!!
    You're welcome! Qaflags sadly isn't a documented variable in AutoCAD, but here's a couple links from two of my favorite sources:
    http://blog.jtbworld.com/2008/07/exp...-autolisp.html
    http://cadpanacea.com/node/266
    You should be able to find everything else in the AutoLISP Reference in AutoCAD Help.
    Tom Beauford P.S.M. - Civil 2013 on Windows 7 Pro
    Design Analysis - Leon County Public Works/Engineering
    2280 Miccosukee Rd. Tallahassee, FL 32308-5310
    Ph# (850)606-1516

Similar Threads

  1. Oh, so close...
    By bowlingbrad in forum AutoCAD Customization
    Replies: 0
    Last Post: 2009-02-17, 05:20 PM
  2. Welcome Screen Will not Close
    By CADdancer in forum ACA General
    Replies: 6
    Last Post: 2008-11-10, 07:03 PM
  3. Pan in vba or something close.
    By kap_78 in forum VBA/COM Interop
    Replies: 1
    Last Post: 2005-09-16, 05:03 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
  •