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

Back again with really tricky problem

8 REPLIES 8
Reply
Message 1 of 9
rodb
336 Views, 8 Replies

Back again with really tricky problem

I have a program that scales the attribute text of a symbol block. Problem is the text insert point is middle so when the text is made bigger it scales outward from the middle causing the text to overlap the symbol. Even when I set the text insert point to bottom middle it still moves away from the symbol. So I guess the text has to be moved away or towards by half the scale factor and the extra problem is sometimes the block is not horzontal but at an angle. Here is the lisp

 

 

;Scale Circuit text size by a factor
(defun restore () ;restore variables
(setq *error* olderr)
(princ)
)

(defun trap (er) ;error trapping
(princ "\nPROGRAM ABORTED ")
(princ er)
(setq *error* olderr)
(princ)
)
(defun c:circuitsize (/ ct e1 e2 ck )
(graphscr)
(setq olderr *error*
*error* trap)

(if (equal userr1 nil)
(setq userr1 1))
(prompt"\nText Scale Factor.. <")
(princ userr1)
(princ ">")
(setq ctch1 (getreal))
(if (not (equal ctch1 nil))(setq userr1 ctch1))
(setq inc userr1)
(prompt "\nPick your Blocks..")
(setq ss (ssget '((0 . "insert")))
sl (sslength ss)
ct 0
ctr 0
ang 0.0
)
(repeat sl
(setq e1 (ssname ss ct))
(setq ck 2)
(while (not (equal ck "SEQEND"))
(setq e1 (entnext e1)
e2 (entget e1)
ck (cdr (assoc 0 e2)))
(if (= (cdr (assoc 2 e2)) "CIRCUIT")
(progn
(setq size (cdr (assoc 40 e2))
newsize (* size inc))
(setq e2 (subst (cons 40 newsize)(assoc 40 e2)e2))
(entmod e2)
(entupd e1)
(setq ctr (+ ctr 1))
)
)

)
(setq ct (+ ct 1))
)
(print ctr)
(princ " Circuits text size increased by: ")
(princ inc)
(princ " to ")
(princ newsize)
(restore)
)

 

 

8 REPLIES 8
Message 2 of 9
hmsilva
in reply to: rodb

rodb wrote:
...
I have a program that scales the attribute text of a symbol block. Problem is the text insert point is middle so when the text is made bigger it scales outward from the middle causing the text to overlap the symbol. Even when I set the text insert point to bottom middle it still moves away from the symbol.
...

possibly already tried, but from what I understand, just changing the text insert point to "center", will do the trick...


hope that helps
Henrique

EESignature

Message 3 of 9
rodb
in reply to: rodb

Oh no that did do the trick, strange when middle also seems to appear to be centered on the centre of the text. Now all I have to do is change one of the attribute tags on 800 blocks from middle to centre!!!!!!! I feel sick! Good thing its snowing this weekend. 

Message 4 of 9
Kent1Cooper
in reply to: rodb


@RodB wrote:

I have a program that scales the attribute text of a symbol block. Problem is the text insert point is middle so when the text is made bigger it scales outward from the middle causing the text to overlap the symbol. Even when I set the text insert point to bottom middle it still moves away from the symbol. So I guess the text has to be moved away or towards by half the scale factor and the extra problem is sometimes the block is not horzontal but at an angle. ...


You didn't attach a drawing or image showing where the Attribute lies relative to the symbol element(s), but surely there's a text justification you could use that would have it increase in size in a direction away from the edges, whether you use center as hmsilva suggests, or top right, or middle left, or any of the thirteen possibilities [discounting Fit and Align in this situation].

Kent Cooper, AIA
Message 5 of 9
rodb
in reply to: rodb

I did try bottom center which I thought would work but it does not.Changing middle to center did work though, I have no idea why! And I have over 1000 blocks to change having just checked how many there are and I have to keep the attributes in the same order and sometimes when you re-block a block it reverses the attribute order. Opening them and saving them directly seems ok. 

Message 6 of 9
rodb
in reply to: rodb

Oops that works fine for the tag scale program but not for the tag rotate program which is even more important. Good thing I checked before I had done only a few. Nope I have to keep the text insert point at middle for some other programs and move the text away when using the scale program. I guess the tag will have a position maybe assoc 10 and some calc will have to be used to shift it. The joys of programming I guess. 

Message 7 of 9
Kent1Cooper
in reply to: rodb


@RodB wrote:

I did try bottom center which I thought would work but it does not.Changing middle to center did work though, I have no idea why! .... 


Bottom-Center justification has the insertion point down at the lowest level of descenders below the baseline [g j p q y / | ( )], even if the text doesn't contain any such characters.  Center justification has it at the level of the baseline, ignoring any actual or possible descenders.  The same difference applies to Bottom-Right vs. Right and to Bottom-Left vs. Left.

Kent Cooper, AIA
Message 8 of 9
rodb
in reply to: Kent1Cooper

Ah that now makes sense, when you click a center justfied text the grip appears to be at the middle like middle justified which is confusing. 

Message 9 of 9
Kent1Cooper
in reply to: rodb


@RodB wrote:

Ah that now makes sense, when you click a center justfied text the grip appears to be at the middle like middle justified which is confusing. 


They may appear to be at about the same place, especially in a font with deeper-than-typical descenders and if you're not zoomed in very close.  But Center justification has the insertion point on the baseline, while Middle has it vertically halfway between the topmost and bottommost extents of the characters used in the Text entity's content.  That's what I find confusing sometimes, because Middle-justified Text in the same font and with the same insertion point can move if you change its text content.  "LIVING ROOM" will be positioned the same as in Middle-Center justification, but if you edit that to "Living Room" it will reposition itself, because of the descender on the "g".  Middle-Center uses the mid-height level of the Text's nominal height above the baseline, which doesn't change with different content.

Kent Cooper, AIA

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

Post to forums  

Autodesk Design & Make Report

”Boost