Jump to content

Problem inserting text with a .scr


Cholomanchuten

Recommended Posts

I have a .scr that states:

 

TEXT 1000,1000,0 40 0 PATOFELIZ

 

 

But Autocad 2008 doesn't insert the text with the command .scr!

It opens a textwindow and invites me to write whatever i want.

I WANT TO INSERT THE TEXT; NOT WRITE IT!

 

 

Does anyone, for god's sake, knows a way around this?

 

Thank you very much. Again, pardon my english, i'm argentino.

Link to comment
Share on other sites

I have 2006, and 2009 (skipped a couple years buying software), however, in 2009 the script prints PATOFELIZ to the screen at the proper location.

 

TEXT      Layer: "0"
                           Space: Model space
                  Handle = 276d
            Style = "Annotative"
       Annotative: Yes
 Annotative scale:  1/8" = 1'-0"
            Font file = romans.shx
            start point, X=1000.00000  Y=1000.00000  Z=  0.00000
paper text height  40.00000
model text height 3840.00000
             text PATOFELIZ
         rotation angle   0.00
            width scale factor   0.75000
        obliquing angle   0.00
       generation normal

 

In 2006 it prints 0 PATOFELIZ at a 40 degree angle at the proper insertion point:

 

TEXT      Layer: "0"
                           Space: Model space
                  Handle = 3816
            Style = "MONOSIFR"
            Font file = MONOSIFR.shx
            start point, X=1000.0000  Y=1000.0000  Z=   0.0000
           height    4.5000
             text 0 PATOFELIZ
         rotation angle  40.00
            width scale factor    1.0000
        obliquing angle   0.00
       generation normal

 

How about replacing the portion of the script with:

 

(command "_text" "1000,1000,0" "40" "0" "TEXTLINE")

 

or is that too cumbersome?

Link to comment
Share on other sites

Alright Lee, everyone here likes entmake so I need to learn to use it. I checked out the post and started with the portion of your code:

 

 
(defun Text (pt hgt str)
 (entmakex (list (cons 0 "TEXT")
                 (cons 10  pt)
                 (cons 40 hgt)
                 (cons 1  str))))

 

Then tried to invoke using:

 

(TEXT '(1000 1000 0) '(40) '(TEXTLINE))

 

and get

 

error: bad DXF group: (40 40)

 

I am trying to learn the entmake, unsure how to pass the variables properly. I did learn what a "NURB" is however.

Link to comment
Share on other sites

Only the point needs to be a list, hence try:

 

(TEXT '(1000 1000 0) 40 "TEXTLINE")

 

Entmake is the quickest way to create an ACAD Entity, and is also pretty robust.

Link to comment
Share on other sites

Excellent, thank you for the clarification. I will try other entmake functions also.

 

Any ideas from all this Cholomanchuten?

 

Chuck

Link to comment
Share on other sites

The functions I provided are set up to use the minimum DXF requirements to create the entity, making for easier use.

 

If you wish to stray from the default Linetype/colour/thickness etc you will need to add those DXF codes to the list. All this is mentioned in the thread I linked you to :)

 

A reference to which group codes require which type of data may be found here.

 

Lee

Link to comment
Share on other sites

Lee, you seem to like using entmake, so I've got a question. I myself haven't used it often, mainly because the things I put in tend to have a lot of different characteristics. For each characteristic, you have to pass the specified variable to the function. Of course, trying to keep code neat and tidy, one would start with the minimum amount of inputs. However, as I go on, I add more and more, which means a lot of going back and updating the old function calls to slap in a bunch of nils or whatever to account for the fact that the function itself has changed. Do you run into this, and if so, do you have a way to keep everything tidy? Or do your entmake functions become long and unwieldy, and all the function calls much longer than they need to be?

Link to comment
Share on other sites

Most of the time that I use entmake, few additional codes are needed so its a quick case of using a function akin to those I linked to. But in the times that I will be creating an object with a lot of extra data, I would either use one of those functions with an extra argument for additonal data, or just create a function specifically for what I am doing - or rather, if I am only creating one instance of an object, just use the entmake in line with the main function.

 

Although VL seems more intuitive with its properties/methods, entmake can be much more concise in some situations and is of course a lot quicker than command calls or VL.

 

Furthermore, data is stored in a list format, and AutoLISP is natively designed to manipulate lists, so its a lot easier to manipulate object properties using entmake over VL. (Example - converting the text to an insert in that other thread).

 

Lee

Link to comment
Share on other sites

THanks everybody. Actually, one of the firsts answers worked for me.

The .scr containing the following code:

 

(command "_text" "1000,1000,0" "40" "0" "TEXTLINE")

 

Works for Autocad 2008.

 

Thanks and good luck!

Link to comment
Share on other sites

Advice taken, I have begun my journey to understand entmake and will try to get out of my old habit of using (command...) all the time.

 

Lee, I have the list of entmakex entities you directed me to, thanks. I decided to take each entity type and attempt to call them by passing the correct arguments to the entmake engine. Simple entities (Line, Circle, Text, etc.) are something that I can achieve. Blocks however are still an enigma. I have looked over some various code and believe that if the block is defined first, then the subentities, then close (END) the block definition, I should see the block appear on the screen.

 

This code create an instance of the block entity in the drawing database, but it does not display on the screen.

 

 
(defun c:LOLLIPOP ()
 (entmake '((0 . "BLOCK")
     (100 . "AcDbEntity")
     (67 . 0)
     (8 . "0")
     (100 . "AcDbBlockReference")
     (66 . 1)
     (2 . "LOLLIPOP")
     (10 0.0 0.0 0.0)
     (70 . 2)
    )
 )
 (entmake '((0 . "CIRCLE")
     (100 . "AcDbEntity")
     (67 . 0)
     (8 . "NewLayer1")
     (100 . "AcDbCircle")
     (10 0.0 3.0 0.0)
     (40 . 1.0)
    )
 )
 (entmake '((0 . "LINE")
     (100 . "AcDbEntity")
     (67 . 0)
     (8 . "NewLayer2")
     (100 . "AcDbLine")
     (10 0.0 0.0 0.0)
     (11 0.0 2.0 0.0)
    )
 )
 (entmake '((0 . "ATTDEF")
     (100 . "AcDbEntity")
     (67 . 0)
     (8 . "NewLayer3")
     (100 . "AcDbText")
     (10 -0.375 2.4375 0.0)
     (40 . 1.125)
     (1 . "X")
     (50 . 0.0)
     (41 . 1.0)
     (51 . 0.0)
     (7 . "MONOSIFR")
     (71 . 0)
     (72 . 4)
     (11 0.0 3.0 0.0)
     (100 . "AcDbAttributeDefinition")
     (3 . "PROMPT X:")
     (2 . "TAGX")
     (70 . 0)
     (73 . 0)
     (74 . 0)
    )
 )
 (entmake '((0 . "ENDBLK") (100 . "AcDbBlockEnd") (8 . "0")))
 (command "_.Layer" "c" "1" "NewLayer1" "c" "2" "NewLayer2" "c" "3" "NewLayer3" "")
 (princ)
)

 

Why does this not display? Also, I used command to change the layer colors. :oops: I looked into entmod, but it does not explain modifying layer properties. Is there a more appropriate way to modify layer properties without the command call?

Link to comment
Share on other sites

Advice taken, I have begun my journey to understand entmake and will try to get out of my old habit of using (command...) all the time.

 

Lee, I have the list of entmakex entities you directed me to, thanks. I decided to take each entity type and attempt to call them by passing the correct arguments to the entmake engine. Simple entities (Line, Circle, Text, etc.) are something that I can achieve. Blocks however are still an enigma. I have looked over some various code and believe that if the block is defined first, then the subentities, then close (END) the block definition, I should see the block appear on the screen.

 

This code create an instance of the block entity in the drawing database, but it does not display on the screen.

 

 
(defun c:LOLLIPOP ()
 (entmake '((0 . "BLOCK")
     (100 . "AcDbEntity")
     (67 . 0)
     (8 . "0")
     (100 . "AcDbBlockReference")
     (66 . 1)
     (2 . "LOLLIPOP")
     (10 0.0 0.0 0.0)
     (70 . 2)
    )
 )
 (entmake '((0 . "CIRCLE")
     (100 . "AcDbEntity")
     (67 . 0)
     (8 . "NewLayer1")
     (100 . "AcDbCircle")
     (10 0.0 3.0 0.0)
     (40 . 1.0)
    )
 )
 (entmake '((0 . "LINE")
     (100 . "AcDbEntity")
     (67 . 0)
     (8 . "NewLayer2")
     (100 . "AcDbLine")
     (10 0.0 0.0 0.0)
     (11 0.0 2.0 0.0)
    )
 )
 (entmake '((0 . "ATTDEF")
     (100 . "AcDbEntity")
     (67 . 0)
     (8 . "NewLayer3")
     (100 . "AcDbText")
     (10 -0.375 2.4375 0.0)
     (40 . 1.125)
     (1 . "X")
     (50 . 0.0)
     (41 . 1.0)
     (51 . 0.0)
     (7 . "MONOSIFR")
     (71 . 0)
     (72 . 4)
     (11 0.0 3.0 0.0)
     (100 . "AcDbAttributeDefinition")
     (3 . "PROMPT X:")
     (2 . "TAGX")
     (70 . 0)
     (73 . 0)
     (74 . 0)
    )
 )
 (entmake '((0 . "ENDBLK") (100 . "AcDbBlockEnd") (8 . "0")))
 (command "_.Layer" "c" "1" "NewLayer1" "c" "2" "NewLayer2" "c" "3" "NewLayer3" "")
 (princ)
)

 

Why does this not display? Also, I used command to change the layer colors. :oops: I looked into entmod, but it does not explain modifying layer properties. Is there a more appropriate way to modify layer properties without the command call?

 

Just a quick and dirty edition

(change textstyle name in the code)

(defun emake_lollipop (p)
 (entmake (list (cons 0 "INSERT")
  (cons 2 "LOLLIPOP")
  (cons 10 p)
  (cons 66 1)
                (cons 62 256)
                (cons 39 0)
                (cons 6 "BYLAYER"))
   )

 (entmake (list (cons 0 "ATTRIB")
                (cons 8  "NewLayer3")
                (cons 10 (mapcar '+ p '(-0.375 2.4375 0.0)))
                (cons 11 (mapcar '+ p '(0.0 3.0 0.0)))
                (cons 40 1)
                (cons 1 "Blablabla")
                (cons 2 "TAGX")
                (cons 70 0)
                (cons 73 0)
                (cons 50 0)
                (cons 41 1)
                (cons 51 0)
                (cons 7 "STANDARD")
                (cons 71 0)
                (cons 72 0)
                (cons 210 (list 0 0 1))
                (cons 73 0)
                (cons 62 256)
                (cons 39 0)
                (cons 6 "BYLAYER"))
   )
 (entmake (list
     (cons 0 "SEQEND")
     (cons 8 "0"))
   )
   )
(defun c:LOLLIPOP ()

 (command "_.Layer" "m" "NewLayer1" "c" "1" "NewLayer1"
   "m" "NewLayer2" "c" "2" "NewLayer2"
   "m" "NewLayer3" "c" "3" "NewLayer3" "")

   (if (not (tblsearch "block" "lollipop"))
   (progn
   (entmake '((0 . "BLOCK")
     (100 . "AcDbEntity")
     (67 . 0)
     (8 . "0")
     (100 . "AcDbBlockReference")
     (66 . 1)
     (2 . "LOLLIPOP")
     (10 0.0 0.0 0.0)
     (70 . 2)
    )
 )
 (entmake '((0 . "CIRCLE")
     (100 . "AcDbEntity")
     (67 . 0)
     (8 . "NewLayer1")
     (100 . "AcDbCircle")
     (10 0.0 3.0 0.0)
     (40 . 1.0)
    )
 )
 (entmake '((0 . "LINE")
     (100 . "AcDbEntity")
     (67 . 0)
     (8 . "NewLayer2")
     (100 . "AcDbLine")
     (10 0.0 0.0 0.0)
     (11 0.0 2.0 0.0)
    )
 )
 (entmake '((0 . "ATTDEF")
     (100 . "AcDbEntity")
     (67 . 0)
     (8 . "NewLayer3")
     (100 . "AcDbText")
     (10 -0.375 2.4375 0.0)
     (40 . 1.125)
     (1 . "X")
     (50 . 0.0)
     (41 . 1.0)
     (51 . 0.0)
     (7 . "STANDARD")
     (71 . 0)
     (72 . 4)
     (11 0.0 3.0 0.0)
     (100 . "AcDbAttributeDefinition")
     (3 . "PROMPT X:")
     (2 . "TAGX")
     (70 . 0)
     (73 . 0)
     (74 . 0)
    )
 )
 (entmake '((0 . "ENDBLK")  (8 . "0"))
   )
)
     )
(while
(setq p (getpoint "\nPick insertion point >> "))
(emake_lollipop p)
)
 (princ)
)

 

After entmakeing block definition you need

to entmake the block instance and attribute reference

the same way as well

 

~'J'~

Link to comment
Share on other sites

All that usage of entmake and you use command to create the layer. Feels like buying a Jaguar, but skimping on the leather seats to save $100.

 

 

Don't mind me, I'm just picking.

Link to comment
Share on other sites

Actually, in my code I omitted the creation of the layers due to the fact that when entmak'ing the block entity, the layers are created automatically. I read this somewhere, and forgot where. Is this a true statement?

 

The reason I did this is because I attempted to entmake the layers first, and while generating errors, found that I didn't have to in a block, but any additional tutorial on correct entmake layer procedure would be greatly appreciated.

 

Chuck

Link to comment
Share on other sites

Wow, four versions to learn from! :)

 

Excellent link, thanks.

Most of the examples (both of mine and Ron's) are in VLA, but Vovka's is a nice entmake one.

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...