Layer to Block LISP

Status
Not open for further replies.

DrMEBrown

Usenet Archive
Joined
Jan 16, 2002
Messages
2
Reaction score
0
I need a Lisp routine to:
For each Layer
Create a Block with the same Name as the Layer
Move ALL the Layers entities to the Block
Put the Block back in the the Drawing (I Dont care what layer)

Any help would be appreciated.

Mark Brown
 
schrieb:
I need a Lisp routine to:
For each Layer
Create a Block with the same Name as the Layer
Move ALL the Layers entities to the Block
Put the Block back in the the Drawing (I Dont care what layer)

Would be a simple thing to do in AutoLISP. I don't like to work for free, however, and it seems that you would benefit commercially from such a function. If you donate in my name US$ 50 to either Amnesty International or Greenpeace and send me proof of the donation, I will do it for you.

Tom Berger
 
Thanks Tom,
I don't mind if the routine is public or not, so I can't justify the cost. I have the following code, but don't know wby the block and insert don't work. I only need a little guidance.

(defun C:LAY2BLK (/ whichlay alayer response)
(setq whichlay (strcase (getstring "Which layers? <*>: "))) (if (= whichlay "") (setq whichlay "*")) (tblsearch "layer" "0" t) (while (setq alayer (tblnext "layer")) (setq alayer (cdr (assoc 2 alayer))) (if (and (/= alayer "ESRI_THEMES") (/= (substr alayer 1 8) "ESRI_SHP") (not (thmexi alayer)) (wcmatch alayer whichlay) ) (progn (initget "Y N") (setq response (getkword (strcat "Define block for layer " alayer "? (Y/<N>): "))) (if (= response "Y")
(progn

(prompt "\nClearing Selections...")
(cmd (list "CLEARSEL"))

(prompt "\nSelecting Selections...")
(cmd (list "xselect" "L" alayer ""))

(prompt "\nMoving Selections to Block...")
(cmd (list "block" alayer 0 "p" ""))

(prompt "\nPutting block back on layer...")
(cmd (list "insert" alayer 0 1 1 0))

(prompt "\n")
)
)
)
)
)
(princ)
)

"Tom Berger" wrote:

schrieb:
>
> I need a Lisp routine to:
> For each Layer
> Create a Block with the same Name as the Layer
> Move ALL the Layers entities to the Block
> Put the Block back in the the Drawing (I Dont care what
layer)
Would be a simple thing to do in AutoLISP. I don't like to work for free, however, and it seems that you would benefit commercially from such a function. If you donate in my name US$ 50 to either Amnesty International or Greenpeace and send me proof of the donation, I will do it for you.

Tom Berger
 
The first point your code will fail is the line
(tblsearch "layer" "0" t) ...
I think you intended to use
(tblnext "layer" T).

You also call a functions (thmexi) and (cmd) that aren't defined anywhere in your code. What are these supposed to do? Are they defined in some other file?
___

wrote:

Thanks Tom,
I don't mind if the routine is public or not, so I can't justify the cost. I have the following code, but don't know wby the block and insert don't work. I only need a little guidance.

(defun C:LAY2BLK (/ whichlay alayer response)
(setq whichlay (strcase (getstring "Which layers? <*>: "))) (if (= whichlay "") (setq whichlay "*")) (tblsearch "layer" "0" t) (while (setq alayer (tblnext "layer")) (setq alayer (cdr (assoc 2 alayer))) (if (and (/= alayer "ESRI_THEMES")
...
 
Status
Not open for further replies.

Latest threads

Back
Top