Re: Problem, need tweak to Lisp code


I need some help with AutoLisp.
>
> I have an AutoLISP routine that saves me time every day, but it's
> missing a couple of tweaks that would really help. A few months ago,
> in response to another question, somebody online pointed me to a Lisp
> routine TX2MTX (available several places online).
>
> This solved my first problem: to convert several adjacent TEXT
> entities into a single MTEXT entity. The way it works, I select the
> TEXT entitites, then click a button, and presto.
>
> However, this leads to another problem. TX2MTX takes the justification
> attribute of the first TEXT element and applies it to the resulting
> MTEXT. However, the documents I'm working with these days are poorly
> formatted. In most cases the draftsman used Left justify for the
> text, and centered another TEXT element underneath it by eyeball. The
> routine converts them both to a single MTEXT, but left-justified. For
> various reasons, I often need this MTEXT to be centered.
>
> Other times, the problem is reversed: The draftsman used Center
> justify and the result needs to be Right or Left.
>
> In these case, I have to change the Properties of the new MTEXT file.
> This only takes a few seconds, but I'm working with dozens of drawings
> at a time, each one with dozens of lines that I'm converting to MTEXT,
> and it's getting very tedious to keep doing the same fix over and over > again.
>
> What I would like is to change the function of TX2MTX and have
> multiple (similar) programs. One button for Top-Left justify, one for
> Top-center, and one for Top-right.
>
> I have looked at the code several times for the past few weeks and I
> can't figure out how to change it. I'm sure for an experienced Lisp
> person it would take just a couple of minutes.
>
> Along with that, I need another change. TX2MTX makes a calculation of
> the required width for the new MTEXT entity, but it's a little off in
> some cases. I want to make it about 10-20% larger in almost every > case.
>
> Finally, the resulting MTEXT has another attribute that is
> inconvenient. The default Line space style is for the line heights to
> be "At least" 1 unit high. Again, for several reason, this is awkward
> and requires a few clicks to fix. I would prefer that the default
> setting be "Exact" (1 unit).
>
> For background: I own AutoCAD LT 2000, as part of my work as a
> technical translator. One of my specialties is AutoCAD drawings, and
> I have another couple of programs to help do this. It is much more
> convenient and faster to translate AutoCAD drawings (for example, into
> Spanish) if the text that is supposed to be together is actually > together.
>
> One example: Say that the drawing includes the text
> STAINLESS
> STEEL
> on two separate TEXT entities. My machine-assisted translation
> software can't know that these are supposed to be related, and if I
> let it, it would translate each term literally. Into Spanish:
> INOXIDABLE
> ACERO
> The problem is that this is backward, in many languages. I would have
> to reverse the resulting AutoCAD drawing.
>
> The Lisp routine that I have improves this process tremendously. But
> especially in the past few weeks, there's still grounds for
> improvement. It takes two-three times as long to pre-process AutoCAD
> files, because I have to adjust the resulting MTEXT item almost every
> time (justification, line spacing)
>
> A long time ago I was a Fortran programmer (don't laugh) and a few
> years ago I took some classes in Scheme (variation of Lisp). That was
> a long time ago and that was nothing like what I need now.
>
> One more thing: I also bought LT Boost Extreme 2004 to make the Lisp
> routines go, and that's been great.
>
> Any pointers? I'm sure that these modifications would take minutes
> for the right guy, and I don't have the time to learn how to do it > myself.
>
>
> --
> Steve M - snipped-for-privacy@houston.rrdirt.com (remove dirt for reply) >
> "For the most part, watching a half hour of television is
> like dying a half hour earlier than you otherwise would."
> -- columnist Don Kaul
Change the alignment of the first string to "center" before making the
MTEXT.
Change the value of the 72 field of the text entity as follows:
(DEFUN C:CTIPC (/ E P P1 P2 DI AN ENTSUB)
; CHANGE TEXT INSERTION POINT TO CENTER
(DEFUN ENTSUB (E I V) (SUBST (CONS I V) (ASSOC I E) E))
(SETQ E (CAR (ENTSEL "\nSelect text to change to center alignment: "))
E (ENTGET E)
P (CDR (ASSOC 10 E))
E (ENTMOD (ENTSUB E 72 1))
E (ENTGET (CDR (ASSOC -1 E)))
P1 (CDR (ASSOC 10 E))
P2 (CDR (ASSOC 11 E))
DI (DISTANCE P1 P2)
AN (ANGLE P1 P2)
P2 (POLAR P AN DI))
(ENTMOD (ENTSUB (ENTSUB E 10 P) 11 P2))
(PRINC))
Hope this helps.
Mitch Thompson
formatting link

Reply to
Mitch Thompson
Loading thread data ...

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.