scale text at insertion point/grips
Hi all,
I'm wondering if anyone has a script that could scale text in place by one of the grips. I'm thinking if it's mtext, you COULD NOT do it, but if it were text, then maybe you could, by grip.
Am I off base here?
Thanks,
bricscad v12.2.17 pro
0
Comments
-
Hi Randy,
On an individual basis you can scale TEXT and MTEXT by selecting a grip point (to make it hot), and then either hitting the space bar or typing in sc to get to the scale option. You can retrieve the bounding box of text in LISP/VBA (textbox / GetBoundingBox), which you could use to establish the same grip point for scaling all your text.
This will routine will scale Text and MTEXT about its insertion point. Note this applies a scale factor, not an absolute height. You could use this as a starting point for what you want to do.
[code]; SCALE TEXT
; will scale TEXT and MTEXT objects about their insertion points
; by the given scale factor
;
; CAD Concepts Ltd.
; http://www.cadconcepts.co.nz
(defun C:SCALETEXT ( / CCL:SCALETXT sset scalefactor num ent)
; Scale a text object about its insertion point
; requires entityname and scalefactor
(defun CCL:SCALETXT (ent scalefactor / obj objip)
(setq obj (vlax-ename->vla-object ent)) ; retrieve the text object
(setq objip (vla-get-InsertionPoint obj)) ; find its insertion point
(vla-ScaleEntity obj objip scalefactor) ; scale the text about its insertion point
); end DEFUN CCL:SCALETXT
; Main program
;------------------------------------------------------------------------------
(princ "\nSelect TEXT and MTEXT to Scale") ; Provide prompt
(setq sset (ssget '((-4 . "")))) ; Allow selection of only TEXT and MTEXT objects
(if (= (type sset) 'PICKSET) ; if user has made a valid selection
(progn ;THEN
(setq scalefactor (getdist "\nEnter Scale Factor: ")) ; ask for a scale factor
(if (= (type scalefactor) 'REAL) ; if user has made a valid entry
(progn ; THEN scale the selected text objects
(setq num 0) ; initialise counter
(repeat (sslength sset) ; repeat for each object in our selection set
(setq ent (ssname sset num)) ; retrieve the entity name
(CCL:SCALETXT ent scalefactor) ; scale object by given scale factor
(setq num (1+ num)) ; Iterate counter to next object in selection set
) ; end repeat
); end progn
(princ "\nValid scale factor not given")
); end if
); end progn
(princ "\nNo TEXT or MTEXT selected")
); end if
(prin1); make a quiet exit
); end DEFUN C:SCALETEXT[/code]
Regards,Jason Bourhill
0 -
Many thanks Jason! Exactly what I needed.0
-
Oops,
the ssget line looks broken, though...
This is probably one of the common small problems that all advanced users have their own routine to deal with, mine is as follows:
[code](prompt "
jyg_scb.lsp - scales texts and block insertions.
10/99 knut hohenberg, no rights reserved.
"
)
(defun C:scb ( / selset n scale object objdat oldecho)
(prompt "Select insertion or text objects: ")
(setq selset (ssget '((-4 . ""))))
(if selset
(progn
(initget 2)
(setq scale (getreal "\nEnter scale factor: "))
(setq n 0.0)
(command "._undo" "_g")
(setq oldecho (getvar "cmdecho"))
(setvar "cmdecho" 0)
(while (setq object (ssname selset n))
(setq objdat (entget object)
inspnt (cdr (assoc 10 objdat))
)
(command "_scale" object "" (trans inspnt 0 1) scale)
(setq n (1+ n))
)
(setvar "cmdecho" oldecho)
(command "_.undo" "_end")
)
(prompt "Nothing appropriate selected ")
)
(princ)
)
(prompt "
...loaded. Type SCB to invoke.
"
)
(princ)[/code]
(may sound heretic, but I wished all that vlxxx stuff would have been constrained to things you couldn't do with plain old AutoLISP)0 -
A very big Oops indeed... after pasting into the code tags, my ssget line has been mutilated as was Jason's... this really needs a fix.
So let's try to paste it as ordinary text:
(prompt "
jyg_scb.lsp - scales texts and block insertions.
10/99 knut hohenberg, no rights reserved.
"
)
(defun C:scb ( / selset n scale object objdat oldecho)
(prompt "Select insertion or text objects: ")
(setq selset (ssget '((-4 . ""))))
(if selset
(progn
(initget 2)
(setq scale (getreal "\nEnter scale factor: "))
(setq n 0.0)
(command "._undo" "_g")
(setq oldecho (getvar "cmdecho"))
(setvar "cmdecho" 0)
(while (setq object (ssname selset n))
(setq objdat (entget object)
inspnt (cdr (assoc 10 objdat))
)
(command "_scale" object "" (trans inspnt 0 1) scale)
(setq n (1+ n))
)
(setvar "cmdecho" oldecho)
(command "_.undo" "_end")
)
(prompt "Nothing appropriate selected ")
)
(princ)
)
(prompt "
...loaded. Type SCB to invoke.
"
)
(princ)0 -
Oh no, my stupidity, of course this doesn't work: the ssget filter contains < and > characters, which are of course interpreted as html-tags.
Seems they have to be replaced manually, so this would be the correct line:
(setq selset (ssget '((-4 . "<OR")(0 . "INSERT") (0 . "TEXT") (0 . "MTEXT") (-4 . "OR>"))))0 -
Oh no, my stupidity, of course this doesn't work: the ssget filter contains < and > characters, which are of course interpreted as html-tags.
Seems they have to be replaced manually, so this would be the correct line:
(setq selset (ssget '((-4 . ""))))
Well, I wouldn't be so hard on yourself... I would have expected pasting it into a code block would preserve such characters...0 -
The Pointy Bracket Problem again.
Time for a solution of sorts:
Attached is a textfile with some javascript that you can copy into the url/location field of a bookmark. Clicking on that bookmark will then "zap" all pointy brackets that you have typed, but not the hidden pointy brackets from html-code that you have pasted (doing that would also remove all line breaks).
- Only works for the BC Forum.
- Tested on IE8.0 and FF12.0.
- If IE gives a "protocol" warning when you create the bookmark, you can just click OK.
- Make sure you copy all the text from the text file. The code had to be put on a single line for IE.
My javascript skills are not that great, but it seems to work OK.
Test 1: <tag> </tag>
Test 2:
[code](vlax-ename->vla-object ename)[/code]
Test 3: <<< >>>0 -
@Greg:
Yes, I also think you could reasonably expect that reserved characters within a code block get replaced with their html names by an input filter - I filed a SR for this, let's see what Bricsys thinks... but pasting as ordinary text was really, really stupid.
@Roy:
Very impressive (like always) - but don't you think this should be fixed by Bricsys in the first place?0 -
I agree. The problem, I believe, is that some people paste text and code with html formatting or just type html tags (to get text in italics for example). A solution might be to have two options for inserting code:
{code=notags} {/code}
{code} {/code}
I have used curly brackets instead of square brackets for obvious reasons...
0 -
Hi all,
sorry for the bung code never thought to check it. However I did include it as a separate file.
I too have raised this with Bricsys. Believe it is in the works for a planned update to the forums. Hopefully this is in the near future.
IMHO I think they should look at something like GeSHi it automatically formats code for a number of languages, including CAD Lisp, and CAD DCL. Attach a screen capture as an example.
Until they fix, I would suggest always attaching any code as a file attachment.
Regards,Jason Bourhill
ScaleText-GeSHi.png0
This discussion has been closed.