Author Topic: Create text lisp?  (Read 10826 times)

0 Members and 1 Guest are viewing this topic.

Robb

  • Guest
Create text lisp?
« on: April 14, 2005, 10:23:44 PM »
Looking for a lisp that will set the style, layer color, and possibly prompt me a scale for text height. Example if I were drawing at 48 scale it will allow me to enter a scale value of 48 for the new text. or something similar.

Thanks.

CADaver

  • Guest
Create text lisp?
« Reply #1 on: April 14, 2005, 10:37:14 PM »
Before someone jumps in with the completed code....

This sounds like an opportunity to learn how to do it for yourself.  Build the "psuedo-code"  That's sort of a road map on what happens and when, it's just a list of steps.  When you've done that, post it here and you'll get a load of help from several real gurus in fleshing it out.

HINT: Find out all the command options and sequences for the -STYLE and -LAYER commands.

Robb

  • Guest
Create text lisp?
« Reply #2 on: April 15, 2005, 06:04:15 PM »
Cadaver, I tried to do it in a lisp but decided to use a pulldown menu.

I added all the commands that I needed to run but I keep getting an error.

What I want is the layer to be set to a TEXT layer with color "4", simplex, .8 width, 1/8 height and end with in the mtext commant to continue typing.

After loading the menu and trying to run one of these commands from the pull down I get an error that the Font is not available. Dont know if that makes sense.

Thanks.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Create text lisp?
« Reply #3 on: April 15, 2005, 06:08:34 PM »
Can you post the code you are using in the menu.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

danny

  • Guest
Create text lisp?
« Reply #4 on: April 15, 2005, 08:07:38 PM »
Robb,
good to see you around again....
try this
Code: [Select]
(defun c:mtxt()
(command "-layer" "n" "YourLayerName" "s" "YourLayerName" "c" "4" "" "")
(COMMAND "-linetype" "s" "BYLAYER" "")(princ)
(command "-style" "YourStyleName" "simplex" ".125" ".8" "" "" "" "")
(COMMAND "_mtext")(princ)
)

CADaver

  • Guest
Create text lisp?
« Reply #5 on: April 16, 2005, 02:19:14 PM »
Danny, ignore Robb's "give you the whole fish"  :P  :roll: and post what you've been working on so far.  An error usually means you've (I've) skipped a prompt in the command sequence along the way.

BTW, the command sequence for a menu pull-down is not all "that" different from lisp.  If you can get your hands around one, you can the other as well.

daron

  • Guest
Create text lisp?
« Reply #6 on: April 18, 2005, 08:29:48 AM »
Cadaver, don't you mean Robb, ignore Danny's...

Plus, if it were me, I'd ignore Danny's code too.

CADaver

  • Guest
Create text lisp?
« Reply #7 on: April 18, 2005, 09:26:53 AM »
Quote from: Daron
Cadaver, don't you mean Robb, ignore Danny's...
oops, typing faster than I can think...  hmmm...  considering I'm using one finger on each hand and taking a wild swipe at the keyboard, that doesn't say much about my thinkin' speed.

...

anyway...

Danny's code gives you BIG hints <grin> on how to do it using (command functions in lisp.  Though there are some here that would frown on the use of (command functions, I'm not one of the them.  I look at it as crawlin' before you walk.  (The walkin' part would be using (entmake function to build the layers and styles without using "command")

Another thought is Danny's code doesn't first check to to see if the style/layer already exists.  Sometimes this may not be necessary, if you want this layer/style to look a certain way no matter what.  Just understand that it will effect elements already plced in the drawing.

ELOQUINTET

  • Guest
Create text lisp?
« Reply #8 on: April 18, 2005, 09:27:24 AM »
maybe you could create a button. someone could help you on setting the text height, don't have time right now.

(setq var (getvar "clayer"));(command "-layer" "n" "text" "c" "WHITE" "text" ) ;setvar clayer "text";mtext;\;_LayerP

daron

  • Guest
Create text lisp?
« Reply #9 on: April 18, 2005, 09:41:21 AM »
Has anybody noticed that Randy was trying to help Robb at least begin this project himself? It is a very simple thing to give him what he has asked for.  Randy didn't want to just give it to him, but probably could have. As far as using command goes, I am not totally against its use. I use it in many applications, but on a limited use and for different reasons. Now, as it is a good way to learn to crawl, let's not let it be a crutch. Randy's last comment shows where command has become a crutch. On a daily basis I have to work with crutch style programming. It sucks. The programs I have to use are riddled with command and user un-friendly (lacking error traps) code.

Dan, why not use "-layer" "m" instead of "n"? You wouldn't have to use setvar if you did and by using "m" instead of "n', if the layer exists it is merely set.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Create text lisp?
« Reply #10 on: April 18, 2005, 10:35:07 AM »
I noticed and was hanging back waiting for the psuedo code to show up.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

CADaver

  • Guest
Create text lisp?
« Reply #11 on: April 18, 2005, 10:45:59 AM »
Quote from: MP
I noticed and was hanging back waiting for the psuedo code to show up.
We may have lost Robb on this one, we may have to assume the psuedo-code ourselves after a while.

I think this is an important little routine, something everyone should understand, and a major step in standardization.  If you can control the layer and style of text, without the user even knowing about it, you've gone a long way in making compliance with the standard easy.

It may seem basic to some, but I think this is a primary building block in the foundation of standardization.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Create text lisp?
« Reply #12 on: April 18, 2005, 10:55:10 AM »
<nodding.mpg>
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Create text lisp?
« Reply #13 on: April 18, 2005, 12:51:38 PM »
Quote from: CADaver
It may seem basic to some, but I think this is a primary building block in the foundation of standardization.


I think this one of the keys to acceptance in standardization.  If the users are "using" the standard without kowing it, or using it and enjoying your code setting things for them, they tend to accept other "standards" more readily because you will "help" them comply.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

CADaver

  • Guest
Create text lisp?
« Reply #14 on: April 18, 2005, 01:52:51 PM »
Quote from: CmdrDuh
Quote from: CADaver
It may seem basic to some, but I think this is a primary building block in the foundation of standardization.


I think this one of the keys to acceptance in standardization.  If the users are "using" the standard without kowing it, or using it and enjoying your code setting things for them, they tend to accept other "standards" more readily because you will "help" them comply.
Exactly, and text layers and styles are the perfect place to start.  That's why I'm hoping Robb steps up for this one.

daron

  • Guest
Create text lisp?
« Reply #15 on: April 18, 2005, 02:52:38 PM »
Did you try PMing him?

CADaver

  • Guest
Create text lisp?
« Reply #16 on: April 18, 2005, 03:07:28 PM »
Quote from: Daron
Did you try PMing him?
Not yet, I was sorta hoping he'd surface on his own.  He may have "work" getting in the way so I was gonna wait til tomorrow.

hyposmurf

  • Guest
Create text lisp?
« Reply #17 on: April 18, 2005, 03:15:27 PM »
I tried doing a similar thing before,but ran into a brick wall.Tried to have the MTEXT command set the layer to my specific text layer and create that layer if it wasnt present.Had to be done by LISP,I tried via macros and resetting my aliases but just didnt work. Here's the thread.

Robb

  • Guest
still here... sorry
« Reply #18 on: April 22, 2005, 05:07:59 AM »
Sorry i've been busy moving... should be done by this weekend. Anyway I think i've figure it out... I didnt have time so I was hoping someone would help me out. I wrote a lisp  to do this a while back but cant seem to find it.

I will give it another shot later and will repost.

Thanks!

CADaver

  • Guest
Create text lisp?
« Reply #19 on: April 22, 2005, 11:51:21 AM »
Here's a sketch of how I've setup our layer/style control.

I have a text style/layer routine (txstla) (long before reactors but looking at that soon) that:

1.)  Reads Current space If it's MS
-- It reads the current DIMSCALE
If the current space is PS
-- It reads the current DIMLFAC

2.)  It then puts together a style/layer name "TEXT" plus the DIMSCALE/DIMLFAC = TEXT48

3.)  It then checks to see if that layer exists, if it does it sets it current, if not it makes it based on a layermake function I have.

4.)  Then it checks is that style exists (TEXT48, we use text height set in the style) if it does it sets it current, if not it creates it based on a sylemake function I have.

Okay, so now I've made or set the right style and layer current in this function.  Notice I didn't collect the current style and layer data for return later.  Basically, I don't care, if the user is in annotation mode, he'll be there a while.

I have another that does nearly the same for DIM style and layers using "DIM" as the prefix.

Now if I had a reactor setup to run these whenever the command was issued it'd be real cool, but I haven't taken the time for that yet.  But what I have done is prefix every possible way a user can inout text with the function (txstla).  All the shorthand functions and autolablers we have, all the menu locations and buttons, yada yada yada, then undefined the MTEXT and TEXT and DTEXT functions entirely and setup MT, TX and DT in thier place.  Someone has to know how to get around it it to screw it up.  One of the things we stress NOT to do in our training sessions.

Now for client specific layer/style names all I need do is modify the (txstla) function and everything is rosy.

hyposmurf

  • Guest
Create text lisp?
« Reply #20 on: May 01, 2005, 05:31:02 PM »
Heres the thread I was refering to before,the one above references this thread. :roll: similar thread topic
Is it possible to have a lisp call a macro and execute it?I have the macro I need to make sure my MTEXT and QLEADER are always on the correct layer.I was previously trying to redefine both those commands in the pgp file using my own macro,but that aint possible.Want to call the commands from the command line,rather than using a menu button.

hyposmurf

  • Guest
Create text lisp?
« Reply #21 on: May 01, 2005, 06:20:06 PM »
OK I've managed to put some lame lisp together and it seems to work.Here it is:

Code: [Select]
(defun C:MTE()
  (command "LAYER" "s" "SML_TEXT" "" "MTEXT")
)


I'd like to have my layer "SML_TEXT" created if it isnt present,but this will do at the moment as I have the layer incorporated in my template file.What is weird though is that when I run my lisp it sets the layer to SML_TEXT and then executes the MTEXT command,but just leaves me to input my text at the command line,no MTEXT eidtor. :( If I then hit enter it exits the MTEXT command.

ronjonp

  • Needs a day job
  • Posts: 7529
Create text lisp?
« Reply #22 on: May 02, 2005, 09:52:18 AM »
Use the make option to ensure the layer is always created. As far as inputting to the command line don't know how to fix that one.

(defun C:MTE()
  (command "LAYER" "m" "SML_TEXT" "" "_.MTEXT")
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

hyposmurf

  • Guest
Create text lisp?
« Reply #23 on: May 12, 2005, 03:39:19 PM »
The problem I have is it will not open the MTEXT editor when I run the lisp,just run MTEXT from the command line. :shock: How do I get round thos one?I am almost there with this lisp,but cant figure out where to go next. :cry:

daron

  • Guest
Create text lisp?
« Reply #24 on: May 12, 2005, 04:12:27 PM »
Lisp doesn't natively handle dialog. You have to call the dialog information or create your own and call to it. Without, you're left on the command line.

hyposmurf

  • Guest
Create text lisp?
« Reply #25 on: May 12, 2005, 04:40:29 PM »
Bummer Ive gone from a macro to lisp and now....?Would I need VB to bring up the MTEXT dialogue box then?I feel Im doomed then until Ive learnt how that all works :(

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Create text lisp?
« Reply #26 on: May 12, 2005, 04:43:22 PM »
Give this a try.
Code: [Select]
(defun C:MTE ()
  (command "LAYER" "m" "SML_TEXT" "")
  (initdia)
  (command "_.MTEXT")
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

daron

  • Guest
Create text lisp?
« Reply #27 on: May 12, 2005, 04:48:36 PM »
Yeah that'll work, but you won't get back into the program if there's anything left for it to do, or am I wrong again?

hyposmurf

  • Guest
Create text lisp?
« Reply #28 on: May 12, 2005, 05:03:05 PM »
Beauty!Cheers CAB :dood: Not sure if that problem will occur maybe CAB will know.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Create text lisp?
« Reply #29 on: May 12, 2005, 05:13:19 PM »
Daron, you are correct.
In that MTE lisp it activates the Mtext command and is done, never to return.
If you want to activate the Mtext command and stay in a lisp you will have to jump through some hoops.
See this post.
http://www.theswamp.org/phpBB2/viewtopic.php?p=62268#62268
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

sourdough

  • Bull Frog
  • Posts: 367
Re: Create text lisp?
« Reply #30 on: May 12, 2005, 07:08:51 PM »
Quote from: Robb
Looking for a lisp that will set the style, layer color, and possibly prompt me a scale for text height. Example if I were drawing at 48 scale it will allow me to enter a scale value of 48 for the new text. or something similar.

Thanks.
LDC 2009/C3D 2010/C3D 2011/C3D 2016

Win 10 64bit

hyposmurf

  • Guest
Create text lisp?
« Reply #31 on: May 13, 2005, 11:34:17 AM »
The same post is here to: here to