Jump to content

Entmake Fields


Steven P

Recommended Posts

Does anyone know if it is possible to entmake a field text? Cheers

 

 

(working on a little function to create blocks... all done with entmakes and was wanting to look at the borders and title blocks next... which have a field.. but I can't work that one out. The function works via the command line, single word to insert a block, quicker than 'insert' skipping the dialogue box, entmakes because that's how I am doing it.)

Link to comment
Share on other sites

Keep in mind a field is linked to an object in a drawing. You have to insert the block first then create the field for it. If you make copies of that block and the field all those fields will reference the original insertion not the copied insertions. If you copy an object with field to another drawing the field will no longer work because the reference has to be set up in the current drawing.

Plenty of useful code out there for labeling blocks using fields just keep in mind they are limited by being directly linked to a specific object in a specific drawing.

http://www.cadtutor.net/forum/showthread.php?51254-Block-s-name-to-FIELD-(based-on-existing-lisp)&p=347968&viewfull=1#post347968

 

  • Like 1
  • Agree 1
Link to comment
Share on other sites

It's entirely possible.
You simply need to retrieve the ID of the object concerned.
You can rely on the text provided in the dialog box when designing the field in manual mode, you just have to be careful to double the "\" character in the lisp code so that it is correctly interpreted.

In lisp we can even have characteristics not accessible in a dialog box, an example of code to have the volume of a 3D solid (impossible to have this property in a dialog box)

 

(vl-load-com)
(defun c:Label_Volume ( / js htx AcDoc Space n obj ename pt alpha nw_obj)
  (princ "\nSelect solid.")
  (while
    (null
      (setq js
        (ssget
          (list
            '(0 . "3DSOLID")
            (cons 67 (if (eq (getvar "CVPORT") 1) 1 0))
            (cons 410 (if (eq (getvar "CVPORT") 1) (getvar "CTAB") "Model"))
          )
        )
      )
    )
    (princ "\nAren't solid!")
  )
  (initget 6)
  (setq htx (getdist (getvar "VIEWCTR") (strcat "\nGive the height of the text <" (rtos (getvar "TEXTSIZE")) ">: ")))
  (if htx (setvar "TEXTSIZE" htx))
  (setq
    AcDoc (vla-get-ActiveDocument (vlax-get-acad-object))
    Space
    (if (= 1 (getvar "CVPORT"))
      (vla-get-PaperSpace AcDoc)
      (vla-get-ModelSpace AcDoc)
    )
  )
  (vla-startundomark AcDoc)
  (repeat (setq n (sslength js))
    (setq
      obj (ssname js (setq n (1- n)))
      ename (vlax-ename->vla-object obj)
    )
    (initget 1)
    (redraw obj 3)
    (setq
      pt (getpoint "\nInsertion point?: ")
      alpha 0.0
      nw_obj
      (vla-addMtext Space
        (vlax-3d-point pt)
        0.0
        (strcat
          "{\\fArial|b0|i0|c0|p34;"
          "%<\\AcObjProp.16.2 Object(%<\\_ObjId "
          (itoa (vla-get-ObjectID ename))
          ">%).Volume \\f \"%lu2%pr2%ps[V=,m³]\">%"
        )
      )
    )
    (redraw obj 4)
    (mapcar
      '(lambda (pr val)
        (vlax-put nw_obj pr val)
      )
      (list 'AttachmentPoint 'Height 'DrawingDirection 'InsertionPoint 'Layer 'Rotation)
      (list 5 (getvar "TEXTSIZE") 5 pt (getvar "CLAYER") alpha)
    )
  )
  (vla-endundomark AcDoc)
  (prin1)
)

 

  • Like 1
Link to comment
Share on other sites

Nice, thanks.....

 

So essentially create the text but include the codes in there - that will work

 

From the examples above these are the important lines? I'll have a play with this later

 

(strcat 
  "%<\\AcObjProp Object(%<\\_ObjId "
  (itoa (vla-get-Objectid obj)) ">%).EffectiveName>%"
)

(strcat "
  "%<\\AcObjProp.16.2 Object(%<\\_ObjId "
  (itoa (vla-get-ObjectID ename))">%).Volume>%"
)

 

Link to comment
Share on other sites

I have a handful of drawings that contain a lot of blocks in them arranged to where I can examine them and added a modified version of Lee's code to quickly label the names of each of them with a field and group the field to the block so they select together for moving them around together.

 

When inserting one of the blocks into another drawing I use the newer -INSERTCONTENT (Command) usually in macros for blocks we often import and since groups don't import the group names do not come in. Didn't like AutoCAD's major changes to the INSERT Command but the new command makes up for it.

Examples: 

^C^Cadcnavigate G:/ENGDESGN/BeaufordT/Blocks/Typicals/Typicals.dwg;

that open them in Design Center which displays the blocks with names making them easy to insert or update.

^C^C-INSERTCONTENT G:/ENGDESGN/BeaufordT/Blocks/Typicals/Typicals.dwg;Modified F Curb;

that inserts the block "Modified F Curb" from the drawing "G:/ENGDESGN/BeaufordT/Blocks/Typicals/Typicals.dwg".

 

Easy-peasy with no coding required.

Link to comment
Share on other sites

"single word to insert a block" -Insert use it in a lisp.

 

Another B22 inserts block with a link to name "22" say in a list.

 

I have a reactor code that lets you type say Bz, B22 etc it will remove the B but keep what is after and use that in a defun which may be a -insert defun. No Dcl.

 

I have posted this before, you could do a Bxx.There is say 26 different versions available. I have Offset Circle Fillet in one version.

 

fillet reactor.lsp

 

 

Edited by BIGAL
  • Like 1
Link to comment
Share on other sites

Posted (edited)

I've never looked at reactors really, but could be a thing to look at one day.

 

This is my current amusement, more visual than remembering all the block names - I think you have posted similar before (a few times).

 

image.png.f357c2c4e8adcff92ad98f19442874d3.png

Edited by Steven P
Link to comment
Share on other sites

Thats an image out of a pop menu, nice thing is when screen is full it supports next so a full screen again. Select image or text.

 

Best is that you can use Notepad to make, the images are slides but I made like a 100 in one go. 

 

menu2.png.31566e48b6a2d6983b201aef0e2412c0.png

 

 

Link to comment
Share on other sites

Yes, that the image of the one I made up - very similar layout to the rest though, it is all working, just got to populate the menus now.

 

(doing it for my amusement and to help my memory with block names, thinking I'll make pseudo tabs for fun (Electrical, Civil, Mechanical, Drawing Utilities and so on))

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