lisp routine to align text to a line
Hi
I'm no lisp programmer.
I used the following lisp routine with a previous employer. Its a great little time saver allowing you to align text to any object line polyline etc just by snaps.
(PROMPT "\nLOADING FILE .........")
;
; CHANGE THE ROTATION OF SELECTED TEXT
(defun C:TT ( / selset newscl l n e as)
(setq olderr *error* *error* err)
(setq selset (ssget))
(command "undo" "begin")
(GETSYS)
;;LCA - COMMENT: The UCS command has new options.
(COMMAND "UCS" "W")
(setq
newrot (getorient "\nNew Orientation, Pick 2 points (Return to leave same): ")
newscl (getreal "\nNew Height (Return to leave same): ")
)
(if selset
(progn
(setq l 0 n (sslength selset))
(while (< l n)
(if (wcmatch (cdr (assoc 0 (setq e (entget (ssname selset l))))) "*TEXT")
(progn
(prompt ".")
(if newscl
(progn
(setq s (cdr (setq as (assoc 40 e))))
(setq e (subst (cons 40 newscl) as e))
(entmod e)
)
)
(if newrot
(progn
(setq s (cdr (setq as (assoc 50 e)))
; cur (getvar "UCSNAME")
; n (cdr (assoc 12 (tblsearch "UCS" cur)))
; m (cdr (assoc 10 (tblsearch "UCS" cur)))
; ax (- (cadr n) (cadr m) ) bx (- (car n) (car m) )
; alpha (atan ax bx)
)
(setq e (subst (cons 50 newrot) as e))
(entmod e)
)
)
)
)
(setq l (1+ l))
)
)
)
;;LCA - COMMENT: The UCS command has new options.
(command "ucs" "p")
(command "osnap" "none")
(command "move" "P" "" pause pause)
(resetsys)
(command "undo" "end")
(princ)
)
I've tried loading it into Bricscad 2016 and running the command but get the following error message in command line
: tt
Select entities:
Entities in set: 1
Select entities:
: undo
Undo: Mark/Back to mark/BEgin set/End set/Control/Auto/: begin
; ----- LISP : Call Stack -----
; [0]...C:TT <<--</b>
;
; ----- Error around expression -----
(GETSYS)
;
"no function definition ; expected FUNCTION at [eval]"
I'd love to get this one working. If anyone knows the solution or alternatively has a Brics lisp that does the same I'd love to hear from you.
Thanks in advance
0
Comments
-
Hi Michael,
looks like your missing the GETSYS and RESETSYS functions. These most likely intended to save and reset system variables. Common ones are CMDECHO and OSMODE. I suggest you look at replacing these with acet-sysvar-set & acet-sysvar-restore, which have been included with BricsCAD LISP since V15. You can find out more on how these functions work by downloading the LISP Developer Support Package.
An alternative may be to download BricsCAD Express Tools from the applications area. This is free and includes the TORIENT command.
Regards,Jason Bourhill
0 -
Thanks JasonIll look into the express toolsMuch apreciatedRegardsMichael0
-
Have you considered just using the "align" tool ?0
-
Actually, I think these routines by Lee Mac would be pretty hard to beat
http://www.lee-mac.com/curvealignedtext.html
http://www.lee-mac.com/dtcurve.html
Regards,Jason Bourhill
0 -
No I wasn't aware of that command.Thanks Patrick0
-
Yes thats what I'm after.Thanks Jason0
-
Lee-Mac.com is the first place I look everytime!Actually, I think these routines by Lee Mac would be pretty hard to beat
http://www.lee-mac.com/curvealignedtext.html
http://www.lee-mac.com/dtcurve.html
Regards,Jason Bourhill0 -
The TORIENT command included with BricsCAD Express Tools works great for regular text, but every time I try to use it for mtext, it throws the angle way off from what it should be. Anyone have a solution for this?
0 -
@Mike what u mean exactly? I couldnt reproduce what u annotated
0 -
See attached. I've included the properties window and tagged the polyline segment used for TORIENT.
0 -
I see. If you are not in UCS this happend.
Ill update the Function. As long u need to set UCS to World, ode the torient and set ucs back0