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

Script to select text and change parameter

3 REPLIES 3
Reply
Message 1 of 4
normad
1104 Views, 3 Replies

Script to select text and change parameter

Hey, Im new to autocad scripting although im familiar with scripting in general.

I want to write a script that will select all text thats inside the current layout's scope, chspace to bring it to paperspace and then change their size.

I would really appreciate some help to point me in the right direction. I still couldnt find a proper reference for all auto lisp commands

Any help is greatly appreciated.

Thanks 🙂

3 REPLIES 3
Message 2 of 4
paullimapa
in reply to: normad

Maybe this can start you off using Lisp:

 

(ssget "X" '((0 . "TEXT"))) ; select all Text objects

(command"_.Tilemode""0") ; goto Paper space

(command"_.Mspace") ; goto Model space

(command"_.Chspace""_P""") ; move all selected Text objects to Pspace

 

Not sure how you would like to change their size though.

You may have to step through each text object using lisp to change the Text's Height


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 3 of 4
hmsilva
in reply to: normad


@normad wrote:

Hey, Im new to autocad scripting although im familiar with scripting in general.

I want to write a script that will select all text thats inside the current layout's scope, chspace to bring it to paperspace and then change their size.

I would really appreciate some help to point me in the right direction.


Hi normad,
the following code is just a demo and a starting point for what you are trying to achieve.
Should work as expected, if the Viewpot is a rectangular one and in WCS...
In this demo, as you have stated
"chspace to bring it to paperspace and then change their size."
I did modified the text size one and half times, as a demo, inside the entmod function.

(defun c:demo ( / ACVP ADOC ENT FLAG FLAG1 I LL MSLLPT MSURPT PSLLPT PSURPT SS UR)
  (if (and
	(= (getvar 'TILEMODE) 0)
	(= (getvar 'CVPORT) 1)
      );; and
    (progn
      (setq flag1 T)
      (vl-cmdf "_.mspace")
      (while (not flag)
	(setq flag1 (getkword "\nActivate the desired viewport, and press ENTER!"))
	(if (and
	      (= (getvar 'TILEMODE) 0)
	      (/= (getvar 'CVPORT) 1)
	      (not flag1)
	    );; and
	  (setq flag T)
	);; if
      );; while
      (setq aDoc (vla-get-activedocument (vlax-get-acad-object))
	    AcVp (vla-get-activepviewport aDoc)
      );; setq
      (vla-put-target AcVp (vlax-3d-point '(0 0 0)))
      (vlax-invoke-method AcVp 'GetBoundingBox 'll 'ur)
      (setq psllpt (vlax-safearray->list ll);; PSpace viewport lower left point
	    psurpt (vlax-safearray->list ur);; PSpace viewport upper right point
	    msllpt (trans psllpt 3 2);; MSpace viewport lower left point
	    msurpt (trans psurpt 3 2);; MSpace viewport upper right point
      );; setq
      (if (setq ss (ssget "_W" msurpt msllpt '((0 . "TEXT"))))
	(progn
	  (vl-cmdf "_.chspace" ss "" "")
	  (repeat (setq i (sslength ss))
	    (setq ent (entget (ssname ss (setq i (1- i)))))
	    (entmod (subst (cons 40 (* (cdr (assoc 40 ent)) 1.5)) (assoc 40 ent) ent))
	  );; repeat
	);; progn
      );; if
    );; progn
    (prompt "\nCommand only allowed in Paper Space!")
  );; if
  (princ)
);; demo

 


@normad wrote:

 I still couldnt find a proper reference for all auto lisp commands

Any help is greatly appreciated.


All the Auto LISP functions, can be found at AutoCAD 2015 Help under AutoCAD Developer Help Home Page in AutoLISP, in AUTOLISP,

under Functions By Name and Feature Reference

 

You may also get some ideas/tutorials at AfraLISP and Lee Mac Programming


HTH
Henrique

EESignature

Message 4 of 4
normad
in reply to: normad

thanks guys 🙂

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

Post to forums  

Autodesk Design & Make Report

”Boost