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

Problem getting this lisp to work

2 REPLIES 2
Reply
Message 1 of 3
zootango
228 Views, 2 Replies

Problem getting this lisp to work

I have an old lisp routine here that will allow you to pick a line of text and will rotate it to zero angle and allow you to replace its location.

 

It had always worked in the past, but for some reason now it does not.

 

Now it just changes the actual text to 0 and allows me to relocate it.

It's supposed to just change the text entity's rotation angle to 0 and allow me to relocate it.

 

Can someone help me with getting this lisp to work?

 

 

;ROTATE TEXT TO 0 DEGREES
;
;
(DEFUN C:R0 ()
  (princ "\nSelect TEXT to rotate: ")
  (SETq a (SSGET))
  (if a (progN
  (command "change" a "" "" "" "" "" "0" "")
(command "move" "P" "")
  )(prompt "\n................nothing selected......Try again!!!   "))
)


2 REPLIES 2
Message 2 of 3
Kent1Cooper
in reply to: zootango


@zootango wrote:

....

Now it just changes the actual text to 0 and allows me to relocate it.

It's supposed to just change the text entity's rotation angle to 0 and allow me to relocate it.

....


It was apparently designed to work with Text whose Style does not have a fixed height, and you're using it on something in a Style that does have a fixed height.  The Change command is therefore not asking for a new height, and therefore the rotation is being fed in as text content.  The last "" is probably recalling the Change command, so the Move command is not being accepted.

 

You can confirm that by trying it on Text in a non-fixed-height [zero in the Style definition] Style.  If that works correctly, and the Style of what it fails on has a fixed height, that's the issue.  It can be handled in a couple of ways, but first check whether that is the source of the problem.

 

By the way, if you don't mind moving it before its rotation is changed to 0, one of those Enters [""] in the Change command is for a new location, and a pause in place of the "" will let you move it there, and eliminate the need for the Move command.

Kent Cooper, AIA
Message 3 of 3
Shneuph
in reply to: Kent1Cooper

I guess that's another reason why to try to avoid using (command "xxxxx" ...), Kent??  Esp. ones with as many options as the 'change' command?

 

You can accomplish it with VisualLISP and avoid the issue.  Minor code upgrade but still not the greatest.  It would be better to loop until a is set instead of just exiting and also checking if a is a text object and has the vla properties used.

 

(DEFUN C:R0 ( / a)
  (vl-load-com)
  (princ "\nSelect TEXT to rotate: ")
  (setq a (car (entsel)))
  (if a
    (progn
      (setq a (vlax-ename->vla-object a))
      (vla-put-rotation a 0.0)
      (command "move" (vlax-vla-object->ename a) "" (vlax-safearray->list (vlax-variant-value (vla-get-insertionpoint a))))
      );progn
    (prompt "\n................nothing selected......Try again!!!   ")
    );if
  );defun

 

---sig---------------------------------------
'(83 104 110 101 117 112 104 64 71 109 97 105 108 46 99 111 109)

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

Post to forums  

Autodesk Design & Make Report

”Boost