Jump to content

Help with a lisp


Guest

Recommended Posts

Hi , I am using this lisp a lot of time. I am trying to change the insert text to annotated. The lisp create the annotate text style . The insert text is in the correct text style but is not annotated . Can any one help ???

 

(defun c:tEST (/ *error* varlist oldvars pt1 tval)
(command "_.-style" "_KEIM" "arial.ttf" "_annotative" "_yes" "_no" 2.5 1.0 0.0 "_no" "_no" "_no")
   (defun *error* (msg)
   (mapcar 'setvar varlist oldvars)
   (if (= msg "")
       (princ "\nText Inserted.")
       (princ "\nEsc or Error Pressed...")
   ) ;_  end if
   (princ)
   ) ;_  end defun
   (setq varlist (list "CMDECHO" "CLAYER")
     oldvars (mapcar 'getvar varlist)
   ) ;_  end setq
   (while (and    (/= (setq pt1 (getpoint "\nSelect Insertion Point: ")) nil)
       (/= (setq tval (getstring t "\nSpecify Text: ")) "")
      ) ;_  end and
   (if (not (tblsearch "Layer" "TEXT"))
       (command "-layer" "m" "TEXT" "")
   ) ;_  end if
   (entmake (list '(0 . "TEXT")
              '(8 . "TEXT")
              (cons 10 pt1)
             (cons 40 (getvar "TEXTSIZE")) 
              (cons 1 tval)
              '(50 . 0.0)
              '(7 . "_KEIM") 
              '(71 . 0)
              '(72 . 0)
              '(73 . 0)
        ) ;_  end list
   ) ;_  end entmake
   ) ;_  end while
   (*error* "")
   (princ)
) ;_  end defun

Link to comment
Share on other sites

It's a crude solution, but it worked for me :P

 

   ) ;_  end entmake
(command "CHPROP" "last" "" "Annotative" "yes" "")
   ) ;_  end while

 

Place that command line part in your code between the 'End entmake' en 'end while' and it should work.

 

The command changes the properties of the last object, and since in this case it's a text you can change the annotative setting.

Link to comment
Share on other sites

Hi OMEGA-ThundeR , thank you for the replay. I did the change and worked ,but i want the paper height to be 2.5 no t 2500 ? Any ideas?

 

(defun c:tEST (/ *error* varlist oldvars pt1 tval)
(command "_.-style" "_KEIM" "arial.ttf" "_annotative" "_yes" "_no" 2.5 1.0 0.0 "_no" "_no" "_no")
   (defun *error* (msg)
   (mapcar 'setvar varlist oldvars)
   (if (= msg "")
       (princ "\nText Inserted.")
       (princ "\nEsc or Error Pressed...")
   ) ;_  end if
   (princ)
   ) ;_  end defun
   (setq varlist (list "CMDECHO" "CLAYER")
     oldvars (mapcar 'getvar varlist)
   ) ;_  end setq
   (while (and    (/= (setq pt1 (getpoint "\nSelect Insertion Point: ")) nil)
       (/= (setq tval (getstring t "\nSpecify Text: ")) "")
      ) ;_  end and
   (if (not (tblsearch "Layer" "TEXT"))
       (command "-layer" "m" "TEXT" "")
   ) ;_  end if
   (entmake (list '(0 . "TEXT")
              '(8 . "TEXT")
              (cons 10 pt1)
             (cons 40 (getvar "TEXTSIZE")) 
              (cons 1 tval)
              '(50 . 0.0)
              '(7 . "_KEIM") 
              '(71 . 0)
              '(72 . 0)
              '(73 . 0)
        ) ;_  end list
   ) ;_  end entmake
(command "CHPROP" "last" "" "Annotative" "yes" "")
   ) ;_  end while
   (*error* "")
   (princ)
) ;_  end defun

Link to comment
Share on other sites

I'm sorry, but can't help you with any 'annotative' based problems. I never use annotative texts.

 

You might need to edit some settings within your SCALELISTEDIT though. Or perhaps you need to change the text height in the above code from 2.5 to 0.0025.

Anyway, there seems to be a factor 1000 problem somewhere :).

Link to comment
Share on other sites

I told to the code that

 

(command "_.-style" "_KEIM" "arial.ttf" "_annotative" "_yes" "_no" 2.5 1.0 0.0 "_no" "_no" "_no")

so the paper space must be 2.5

 

I can not understand

Link to comment
Share on other sites

Why not? It does what was asked right? Set the text object annotative?

 

What is the problem? You need to change something else too?

Link to comment
Share on other sites

When i run the same lisp in the drawing gives me any time other paper space. Tha paper space must be 2.5 all the times. My annotatine scale settings is correct.All the problem is in my code , and i dont know fix it

Link to comment
Share on other sites

Can you write out the things you would do manually to achieve the correct settings?

 

Something like;

 

- Run TEXT command

- Place text (and give it x.x height and what other settings)

- Go to properties

- Change to annotative

- Set up the right scales

- etc

Link to comment
Share on other sites

(defun c:txt2 (/ *error* varlist oldvars pt1 tval)
(command "_.-style" "_KEIM" "arial.ttf" "_annotative" "_yes" "_no" 2.5 1.0 0.0 "_no" "_no" "_no")
   (defun *error* (msg)
   (mapcar 'setvar varlist oldvars)
   (if (= msg "")
       (princ "\nText Inserted.")
       (princ "\nEsc or Error Pressed...")
   ) ;_  end if
   (princ)
   ) ;_  end defun
   (setq varlist (list "CMDECHO" "CLAYER")
     oldvars (mapcar 'getvar varlist)
   ) ;_  end setq
   (while (and    (/= (setq pt1 (getpoint "\nSelect Insertion Point: ")) nil)
       (/= (setq tval (getstring t "\nSpecify Text: ")) "")
      ) ;_  end and
   (if (not (tblsearch "Layer" "TEXT"))
       (command "-layer" "m" "TEXT" "")
   ) ;_  end if
   (entmake (list '(0 . "TEXT")
              '(8 . "TEXT")
              (cons 10 pt1)
             (cons 40 0.0125) 
              (cons 1 tval)
              '(50 . 0.0)
              '(7 . "_KEIM") 
              '(71 . 0)
              '(72 . 0)
              '(73 . 0)
        ) ;_  end list
   ) ;_  end entmake
(command "CHPROP" "last" "" "Annotative" "yes" "")
   ) ;_  end while
   (*error* "")
   (princ)
) ;_  end defun

 

When i have the scale to 1:1 and run the code works for all scales.

When i change the scale to 1:200 or 1:500 etc and run again the code , all the results are wrong. i want to give the same results with all scales

Link to comment
Share on other sites

As far as i can tell there is nothing wrong with the lisp routine. The text is 2.5 high.

 

You need to add the right scales to the SCALELISTEDIT list.

Then you need to add the right scales (you might have more) to the text you want to show in the viewport.

To set the right scales select the text, go to the properties window and click the smal icon to the right when selecting 'Annotative Scales' (standard 1:1?). Add the scales you want.

Then in paperspace you create a viewport and select that viewport border and set it to the right Annotative scale in the properties window. This is not the same as the viewport scale! (standard scale in properties window).

 

If you set the SCALELISTEDIT right and set the right scales to the text and viewport it should work. This thread makes me learn more and more about annotative scales :) but it works perfect on my end.

Link to comment
Share on other sites

Now is working

(defun c:txt2 (/ *error* varlist oldvars pt1 tval)
(command "_.-style" "_KEIM" "arial.ttf" "_annotative" "_yes" "_no" 2.5 1.0 0.0 "_no" "_no" "_no")
   (defun *error* (msg)
   (mapcar 'setvar varlist oldvars)
   (if (= msg "")
       (princ "\nText Inserted.")
       (princ "\nEsc or Error Pressed...")
   ) ;_  end if
   (princ)
   ) ;_  end defun
   (setq varlist (list "CMDECHO" "CLAYER")
     oldvars (mapcar 'getvar varlist)
   ) ;_  end setq
   (while (and    (/= (setq pt1 (getpoint "\nSelect Insertion Point: ")) nil)
       (/= (setq tval (getstring t "\nSpecify Text: ")) "")
      ) ;_  end and
 (command "_.-text" "_justify" "_bl" pt1 "" tval)
   ) ;_  end while
   (*error* "")
   (princ)
) ;_  end defun

Link to comment
Share on other sites

  • 2 weeks later...

I found an angle rottation error in the code # 15. Can any one help ?

 

In the beginnig the code was

 

(entmake (list '(0 . "TEXT")
              '(8 . "TEXT")
              (cons 10 pt1)
             (cons 40 0.0125) 
              (cons 1 tval)
              '(50 . 0.0)
              '(7 . "_KEIM") 
              '(71 . 0)
              '(72 . 0)
              '(73 . 0)
        ) ;_  end list
   ) ;_  end entmake

Link to comment
Share on other sites

Was angle 90 degrees out, you set it to 0.0 may be need to set the direction and radians from units, these are variables you can set, may be these (SETVAR "LUNITS" 2) (SETVAR "ANGDIR" 0)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...