Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Basic lisp to bind xref's explode the blocks then layer isolate layer

10 REPLIES 10
Reply
Message 1 of 11
bgraverholt
2044 Views, 10 Replies

Basic lisp to bind xref's explode the blocks then layer isolate layer

I am trying to work on  a lisp where It binds (insert) all xrefs in a drawing, the selects all blocks and explode, then layer isoloate floor plan layer, select all floor plan objects scale down .001.

 

The code below is basic and gets stuck on the explode section.

 

(defun c:keyplan ()
  (setvar "BINDTYPE" 1)
  (command "_-xref" "_bind" "*")
  (command ".explode" "all" "")
  (command "layiso" "*floor*plan*" "" "scale" "all" "" ".001")
  (princ)
)
Tags (3)
10 REPLIES 10
Message 2 of 11
Moshe-A
in reply to: bgraverholt

Hi,

 

Unfortunately, an explode command coming from (command) function accepts only one argument

to overcome this there is an undocumented system variable called QAFLAGS

if it set to 1, the explode will work as expected

 

cheers

Moshe

 

 

 

Message 3 of 11
ВeekeeCZ
in reply to: bgraverholt

Use (initcommandversion) to allow multiple selection in lisp version of the explode command.

 

The layer isolation command does not work that way. Use the  -LAYER command instead. Turn off all layers first, then use your wildcard pattern to turn on layers you want.

 

Where is the base point for the SCALE command. Is it '(0 0 0) ?

Message 4 of 11
bgraverholt
in reply to: Moshe-A

I added the following that I found on line but it still gets hung up on the explode command. I have tried all instead of * and still nothing. I know I still have something wrong lol

 

(defun c:keyplan ()
  (setvar "BINDTYPE" 1)
  (command "_-xref" "_bind" "*")
  (setvar "qaflags" 1)
  (command ".explode" (ssget) "" "*")
  (setvar "qaflags" 0)
  (command "layiso" "*floor*plan*" "" "scale" "all" "" ".001")
  (princ)
)
Message 5 of 11
Moshe-A
in reply to: bgraverholt

 

this is wrong

(command ".explode" (ssget) "" "*")

 

this is good

(command ".explode" (ssget) "")

 

 

Message 6 of 11
bgraverholt
in reply to: Moshe-A

When running that it will also hang up and ask me to select blocks. This is what the command line states when I run it.

 

Duplicate Block "HC-SYMB" ignored.
Command: .explode
Select objects:

Message 7 of 11
Moshe-A
in reply to: bgraverholt

Seperate your lisp to tasks:

 

1) prepare a drawing with binded xrefs

2) activate the explode on them, fix your code until it works

3) the (command "layiso")  is wrong and redundant

 

it is not good coding to invoke (ssget) as an argument to (command) function...cause if the selection yield noting, your program will be fail on the explode command and probably continue to fail on scale

 

you do not need to isolate layers in order to select objects on specific layers, instead (ssget) function has a filter argument which can select all

objects on specific layers.

 

check this:

 

(if (setq ss (ssget))
 (progn
  (setvar "qaflags" 1)
  (command ".explode" "si" ss)   ; the "SI" argument means "single" options for select objects 
                                 ; which spare the need for enter to finish the selction objects
  (setvar "qaflags" 0)
   
  (if (setq ss (ssget "x" '((8 . "*floor*plan*")))) ; select all objects on "*floor*plan*" layers
    						    ; the "x" argument disable pausing for auto select 
   (command ".scale" "si" ss "0,0" "0.001")         ; then scale by 0.001
  )
 ); progn
); if

 

 

why scale by 0.001? if the objects are small you wont see the any change.

 

Moshe

Message 8 of 11
bgraverholt
in reply to: Moshe-A

That does work but it still requires input from user to explode the xref blocks. Is there away to select all and explode? For the scaling down everything on floor plan it doesn't include blocks that are on layer 0 but the objects inside the block are on floor plan layer. Is there a way to include them also? It would be best if it would layer isolated floor plan first before scaling for the fact that the drawing has multiple other layers in the drawings so when it scales down you have to go find the scaled down floor plan at 0,0 rather than doing a general selection to find the floor plan. 

Message 9 of 11
DannyNL
in reply to: bgraverholt

This will explode all blocks in your drawing. 

Replace your (command "explode"...) with (ExplodeAllBlocks)

 

 

(defun ExplodeAllBlocks (/ EAB_BlockSelection)
   (if
      (setq EAB_BlockSelection (ssget "_X" '((0 . "INSERT"))))
      (progn
         (foreach EAB_Entity (ssnamex EAB_BlockSelection)
            (vl-catch-all-apply 'vla-Explode (list (vlax-ename->vla-object (cadr EAB_Entity))))
         )
      )
   )
)

(defun c:keyplan ()
  (setvar "BINDTYPE" 1)
  (command "_-xref" "_bind" "*")
  (setvar "qaflags" 1)
  (ExplodeAllBlocks)
....
....
....

 

Message 10 of 11
bgraverholt
in reply to: DannyNL

For what ever reason I am having a hard time following what I need to all show in this lisp. I know I need to isolate floor plan and still scale everything down by .001 but do I just add that after the code you wrote?

Message 11 of 11
Kent1Cooper
in reply to: bgraverholt


@bgraverholt wrote:

That does work but it still requires input from user to explode the xref blocks. Is there away to select all and explode? ..... 


Don't use (ssget) -- that's what's asking the User for input.

 

(command ".explode" "_all" "")

Kent Cooper, AIA

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Autodesk Design & Make Report