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

Mtext on single line with lisp

33 REPLIES 33
SOLVED
Reply
Message 1 of 34
sovby
2514 Views, 33 Replies

Mtext on single line with lisp

How can i force mtext to be on a single line with lisp? I've tried this a couple of different ways but i cant seem to make it work. It keeps putting the text on several lines without a defined width. The mtext that i normally have in a drawing has a defined width. Here is what i currently have.

 

(COMMAND "-MTEXT" "15.9778,19.5211" "15.9778,24.6157" "S" "ARIAL" "H" "0.1145" "J" "ML" "W" "" "TEXT" "")

33 REPLIES 33
Message 21 of 34
sovby
in reply to: hmsilva

Yes, That sounds right. If the variable "pjt" is set to one of those 5 settings, projectname is set to "Wendys", & useri3 is set to "0" i want the routine to enter the first mtext statement. If "pjt" is set to "IA (New York Remodel)", projectname is set to "Wendys", & useri3 is set to "0" i want the routine to issue the second mtext statement.

Message 22 of 34
hmsilva
in reply to: sovby


@sovby wrote:

Yes, That sounds right. If the variable "pjt" is set to one of those 5 settings, projectname is set to "Wendys", & useri3 is set to "0" i want the routine to enter the first mtext statement. If "pjt" is set to "IA (New York Remodel)", projectname is set to "Wendys", & useri3 is set to "0" i want the routine to issue the second mtext statement.


(if (and (= (strcase (GETVAR "PROJECTNAME")) "WENDYS")(= (getvar "useri3") 0))
  (cond ((or (= "pjt" "IA (SQE2000)")(= "pjt" "IA (NRE2000)")(= "pjt" "IA (E2000)")(= "pjt" "IA (CG3480 REMODEL)")(= "pjt" "IA (E2000 REMODEL)"))
           (Command "-layer" "s" "A-ANNO-TEXT" "" )
           (COMMAND "-MTEXT" "15.9778,19.5211" "S" "ARIAL" "H" "0.1145" "J" "ML" "W" "" (STRCAT(STRCASE ln6) (STRCASE ln7a)) "")
         )
        ((= "pjt" "IA (NEW YORK REMODEL)")
         (Command "-layer" "s" "A-ANNO-TEXT" "" )
         (COMMAND "-MTEXT" "15.9778,19.4235" "S" "ARIAL" "H" "0.1145" "J" "ML" "W" "" (STRCASE ln6) (STRCASE ln7) "")
          ;; 2 strings, to be only one (strcat (STRCAT(STRCASE ln6) (STRCASE ln7)))
         (COMMAND "QSAVE")
         (setvar "useri3" 1)
         )
        );; cond
  );wendys
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 

Henrique

EESignature

Message 23 of 34
sovby
in reply to: hmsilva

Still doesnt work. This is a head scratcher. It doesnt give me any errors, It just doesnt do anything. There is something missing. There is something i am just not thinking about. could it be its not reading the "pjt" from the asci file?

Message 24 of 34
sovby
in reply to: sovby

Well, i changed some things just tying to fix the problem. Now its telling me i have a bad argument. Programming is really difficult at times. My brain really hurts right now. I guess its time to let this go for today & pick it back up tomorrow when my mind is fresh.

 

; error: bad argument type: stringp nil

 

(if (and (= (strcase (GETVAR "PROJECTNAME")) "WENDYS")(= (getvar "useri3") 0))
(cond ((or (= ln16 "IA (SQE2000)")(= ln16 "IA (NRE2000)")(= ln16 "IA (E2000)")(= ln16 "IA (CG3480 REMODEL)")(= ln16 "IA (E2000 REMODEL)"))
(Command "-layer" "s" "A-ANNO-TEXT" "" )
(COMMAND "-MTEXT" "15.9778,19.5211" "S" "ARIAL" "H" "0.1145" "J" "ML" "W" "" (STRCAT(STRCASE ln6) (STRCASE ln7a)) "")
)
((= ln16 "IA (NEW YORK REMODEL)")
(Command "-layer" "s" "A-ANNO-TEXT" "" )
(COMMAND "-MTEXT" "15.9778,19.4235" "S" "ARIAL" "H" "0.1145" "J" "ML" "W" "" (STRCASE ln6) (STRCASE ln7) "")
;; 2 strings, to be only one (strcat (STRCAT(STRCASE ln6) (STRCASE ln7)))
(COMMAND "QSAVE")
(setvar "useri3" 1)
)
);; cond
);wendys
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Message 25 of 34
hmsilva
in reply to: sovby

Sorry,

yesterday I was trying to debug your code in 'notepad' and I didn't realize that you were trying to test a string instead of a variable, in (= "pjt" "IA (SQE2000)") "pjt" is just a string not a variable containing a string, so try

 

(if (and (= (strcase (getvar "PROJECTNAME")) "WENDYS")(= (getvar "useri3") 0))
  (cond ((or (= pjt "IA (SQE2000)")
             (= pjt "IA (NRE2000)")
             (= pjt "IA (E2000)")
             (= pjt "IA (CG3480 REMODEL)")
             (= pjt "IA (E2000 REMODEL)")
         )
           (command "_.-layer" "s" "A-ANNO-TEXT" "" )
           (command "_.-mtext" "15.9778,19.5211" "S" "ARIAL" "H" "0.1145" "J" "ML" "W" "" (strcat (strcase ln6) (strcase ln7a)) "")
         )
        ((= pjt "IA (NEW YORK REMODEL)")
         (command "-layer" "s" "A-ANNO-TEXT" "" )
         (command "_.-mtext" "15.9778,19.4235" "S" "ARIAL" "H" "0.1145" "J" "ML" "W" "" (strcase ln6) (strcase ln7) "")
          ;; 2 strings, to be only one (strcat (STRCAT(STRCASE ln6) (STRCASE ln7)))
         (command "_.qsave")
         (setvar "useri3" 1)
         )
        );; cond
  );wendys
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 Please have in mind that he first few expressions to be tested are the 'PROJECTNAME' and 'useri3', if not 'WENDYS' and '0', the following conditions will not be evaluated...

 

Henrique

EESignature

Message 26 of 34
sovby
in reply to: sovby

I got locked out of my remote access to my work computer so I can't test that right now. Hopefully my "IT" guy can get me on. I really don't feel like going to office today. I thought that maybe I should be putting in ln16 instead of "pjt". If you look at the rest of the routine that's what it does. It reads ln# which is from the asci file that is created by other routine
Message 27 of 34
sovby
in reply to: sovby

Ok, i got back in to remote access. I tried your code & it still doesnt do anything. I then tried my idea & it gives me the bad argument message. Im not sure what to try now.i set projectname to some of the other settings & those arent working either so ive got something totally messed up here. i will have to start over. Tomorrow i will get one of my coworkers to restore this to what it was before i started messing with it.

Message 28 of 34
hmsilva
in reply to: sovby

The '; error: bad argument type: stringp nil'

in this piece of code, can only result from


(STRCAT (STRCASE ln6) (STRCASE ln7a))
or
(STRCASE ln6) (STRCASE ln7)

 

the strcat function is expecting a string as argument and a nil is passed as argument...

at least one of the ln6 ln7 or ln7a variables is nil

 

Henrique

EESignature

Message 29 of 34
dbroad
in reply to: sovby

As you said, there is little purpose using mtext where text will do unless you want to use a background mask, special characters not available in text, or multiple formats in a single string.  So I suggest:

 

(command "text" <your justification> <your insertion point> <your height> <your rotation> <your text>)

 

For the few situations that you might want to convert, just use txt2mtxt.

Architect, Registered NC, VA, SC, & GA.
Message 30 of 34
sovby
in reply to: dbroad

Finally got this to work. I think i was including the whole thing in a progn statement instead of two seperate progn statements. One for each condition. Also it should have been a variable ln16 which is created by my other routine & not "plt" string. This routine reads the asci file & if it has the appropriate variable it executes the mtext command. I also needed to add an additional (If (= (getvar "useri3") 0). Here is a sample of the code of anyone is interested. Thanks to Hmsilva for all the help. There may be a way ogmaking this a little simpler but for today at least it works.

 

(If (OR (= ln16 "IA (SQE2000)")(= ln16 "IA (NRE2000)")(= ln16 "IA (E2000)")(= ln16 "IA (CG3480 REMODEL)") (= ln16 "IA (E2000 REMODEL)"))
(PROGN
(If (= (getvar "useri3") 0)
(progn
(Command "-layer" "s" "A-ANNO-TEXT" "" )
(COMMAND "-MTEXT" "15.9271,19.3658" "S" "Arial" "H" "0.1145" "J" "ML" "W" "" (STRCAT (STRCASE ln6) ", " (STRCASE ln7)) "")
(COMMAND "QSAVE")
(setvar "useri3" 1)
);Second Progn
);Second IF
);First PROGN

(If (= ln16 "IA (NEW YORK REMODEL)")
(If (= (getvar "useri3") 0)
(progn
(Command "-layer" "s" "A-ANNO-TEXT" "" )
(COMMAND "-MTEXT" "7.6083,19.9304" "S" "BORDER" "H" "0.2500" "J" "MC" "W" "" (STRCASE ln6) (STRCASE ln7) "")
(COMMAND "-MTEXT" "2.2181,18.3232" "S" "S1" "H" "0.0781" "J" "TL" "W" "" (STRCAT (STRCASE ln6) ", " (STRCASE ln7)) "")
(COMMAND "QSAVE")
(setvar "useri3" 1)
);Third Progn
);Fourth if
);Third if

)

Message 31 of 34
hmsilva
in reply to: sovby

Glad you got a solution, sovby.

 

Your code can probably be written like this:

 

(cond ((and (OR (= ln16 "IA (SQE2000)")(= ln16 "IA (NRE2000)")(= ln16 "IA (E2000)")(= ln16 "IA (CG3480 REMODEL)")(= ln16 "IA (E2000 REMODEL)"))
            (= (getvar "useri3") 0)
       )
       (Command "-layer" "s" "A-ANNO-TEXT" "" )
       (COMMAND "-MTEXT" "15.9271,19.3658" "S" "Arial" "H" "0.1145" "J" "ML" "W" "" (STRCAT (STRCASE ln6) ", " (STRCASE ln7)) "")
       (COMMAND "QSAVE")
       (setvar "useri3" 1)
       )
      ((and (= ln16 "IA (NEW YORK REMODEL)")
            (= (getvar "useri3") 0)
       )
       (Command "-layer" "s" "A-ANNO-TEXT" "" )
       (COMMAND "-MTEXT" "7.6083,19.9304" "S" "BORDER" "H" "0.2500" "J" "MC" "W" "" (STRCASE ln6) (STRCASE ln7) "")
       (COMMAND "-MTEXT" "2.2181,18.3232" "S" "S1" "H" "0.0781" "J" "TL" "W" "" (STRCAT (STRCASE ln6) ", " (STRCASE ln7)) "")
       (COMMAND "QSAVE")
       (setvar "useri3" 1)
       )
      );; cond

 

One question, you don't need to test the 'PROJECTNAME' anymore?

 

Henrique

EESignature

Message 32 of 34
sovby
in reply to: hmsilva

Yes thats true, not for this routine anyway. We decided we could do it using the variable that the projectstart routine creates in the asci file. I needed some way to differentiate between the different project types.We have a client that has projects in New York city. They have to have a different titleblock & coversheet than projects for the same client in every other state. We still use the projectname for our plotting routine. Id love to find a way to combine all of these into one because right now its a 3 sor 4 step process to start a project. We havent figured out how to do this with one routine because it requires opening up two drawings & once we open up one drawing the routine ends & we need to use another routine for the next step.Im not sure you can do it with straight up lisp or not. 


@hmsilva wrote:

Glad you got a solution, sovby.

 

Your code can probably be written like this:

 

(cond ((and (OR (= ln16 "IA (SQE2000)")(= ln16 "IA (NRE2000)")(= ln16 "IA (E2000)")(= ln16 "IA (CG3480 REMODEL)")(= ln16 "IA (E2000 REMODEL)"))
            (= (getvar "useri3") 0)
       )
       (Command "-layer" "s" "A-ANNO-TEXT" "" )
       (COMMAND "-MTEXT" "15.9271,19.3658" "S" "Arial" "H" "0.1145" "J" "ML" "W" "" (STRCAT (STRCASE ln6) ", " (STRCASE ln7)) "")
       (COMMAND "QSAVE")
       (setvar "useri3" 1)
       )
      ((and (= ln16 "IA (NEW YORK REMODEL)")
            (= (getvar "useri3") 0)
       )
       (Command "-layer" "s" "A-ANNO-TEXT" "" )
       (COMMAND "-MTEXT" "7.6083,19.9304" "S" "BORDER" "H" "0.2500" "J" "MC" "W" "" (STRCASE ln6) (STRCASE ln7) "")
       (COMMAND "-MTEXT" "2.2181,18.3232" "S" "S1" "H" "0.0781" "J" "TL" "W" "" (STRCAT (STRCASE ln6) ", " (STRCASE ln7)) "")
       (COMMAND "QSAVE")
       (setvar "useri3" 1)
       )
      );; cond

 

One question, you don't need to test the 'PROJECTNAME' anymore?

 

Henrique




Message 33 of 34
hmsilva
in reply to: sovby


@sovby wrote:

 We havent figured out how to do this with one routine because it requires opening up two drawings & once we open up one drawing the routine ends & we need to use another routine for the next step.Im not sure you can do it with straight up lisp or not. 


Probably will not be possible with just a routine.
Possibly, using a script file to open a dwg, run some routines, close the file, open the other dwg, run the others routines, might do the trick.
Henrique

EESignature

Message 34 of 34
limich
in reply to: sovby

Thank you so much for the person who told me how to get rid the exclamation marks in my drawings.  I tried to reply but it bounced back.

 

Now, my only other problem for now with the 2015 version is.  I have drawn my arrows.  I then try to type 'Structural beams'  etc and other labels on the drawings.

 

It does not matter whether I click once or twice next to the text, nothing happens.  As soon as I click away from the text box my text disappears.  Before that happens I try to access the icons on the tool bar and the COMMAND line, but they are frozen.

 

Any ideas anyone.  I would love to get this assessment in sometime soon.

Thanks

 

Diane

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

Post to forums  

”Boost