Create lisp

Create lisp

pkambhampati7FA2R
Observer Observer
533 Views
6 Replies
Message 1 of 7

Create lisp

pkambhampati7FA2R
Observer
Observer

Hi, can someone help me create a lisp that goes:

 

Lisp (least clicking)

ssget (_x) [select objects layer]

Saveas

Close

0 Likes
534 Views
6 Replies
Replies (6)
Message 2 of 7

Kent1Cooper
Consultant
Consultant

@pkambhampati7FA2R wrote:

....

ssget (_x) [select objects layer]

Saveas

Close


It's not clear to me what you intend.  Is it to have the routine select all objects on the Layer of a selected object, and send them off to a separate drawing file?  [That would involve a WBLOCK rather than a SAVEAS command.]

Kent Cooper, AIA
0 Likes
Message 3 of 7

pkambhampati7FA2R
Observer
Observer

Thanks for responding!! I have found a way to unformat the mtext in a file, using a lisp:

 

(defun c:MtextUnformat ( / e i e)

(if (setq s (ssget '((0 . "MTEXT"))))
(repeat (setq i (sslength s))
(setq e (ssname s (setq i (1- i))))
(setpropertyvalue e "Contents"
(getpropertyvalue e "Text"))))
(princ)
)

 

However, I want something with least clicks that just selects objects by their layers, saves and closes.

0 Likes
Message 4 of 7

Kent1Cooper
Consultant
Consultant

@pkambhampati7FA2R wrote:

.... I want something with least clicks that just selects objects by their layers, saves and closes.


That's part of what I don't understand--you don't say anything about what to do with the objects selected.  What do you really mean by "just selects objects by their layers"?  Does the User select some object, and the routine finds everything else on the same Layer as that object?  Does the routine step through all Layers, finding everything on each Layer in turn, and do something with them for each Layer's worth, without User input?  What do you mean by "saves"?  Saves the selected objects on a given Layer out to another drawing?

Kent Cooper, AIA
0 Likes
Message 5 of 7

pkambhampati7FA2R
Observer
Observer

Sorry I wasn't clear. I meant saving in the same drawing. However, I'd like to know if there's a way to do that to multiple CAD drawings at once.

0 Likes
Message 6 of 7

Kent1Cooper
Consultant
Consultant

@pkambhampati7FA2R wrote:

..... I meant saving in the same drawing. ....


How does selecting objects by their Layers relate to that?

Kent Cooper, AIA
0 Likes
Message 7 of 7

paullimapa
Mentor
Mentor

this will allow you to do a single click selecting only MTEXT on the current Layer:

(setq s(ssget "_+.:E:S" (list(cons 0 "MTEXT")(cons 8 (getvar"clayer")))))

this will do a save:

(command"_.QSAVE")

this will close drawing:

(command"_.CLOSE")

To apply your code to multiple drawings, create a SCRIPT file (name with .SCR file extension) that includes loading of your lisp routine and running the command ie:

(load"MtextUnformat")

MtextUnformat

 

Then download the free AutoScript app to have this script file applied to multiple drawings:

https://www.cadig.com/products/autocad-script-pro.php

 

But you'll have to modify your code because it won't pause for you to select your MTEXT.

You can change it so that it just selects ALL MText on the current Layer and then cycle through those MText objects selected (if any) to apply the rest of your code:

(setq s(ssget "_X" (list (cons 0 "MTEXT") (cons 8 (getvar"clayer")))))


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes