Jump to content

Recommended Posts

Posted (edited)

Hi, is there a way how to find out what entities are used (associated) with the field formula? For example I have a dynamic block. There are a lot of lines and there is one attribute with the filed formula. This formula reads for example lenght of two lines used in the block and counts both lenghts together. How can I find out which lines are counted?

 

I need it because I did this comlicated block few years ago and I do not remember formula correctly. I have to edit something in it (add few brackets around some parts of the formula), but when I do so everywhere it shows #### symbols. I try attsync, battman, but without success. I do not know how to repair it (dynamic block with attributes and fields)........this is the wortst thing when I work with dynamic blocks.....

 

Many thanks.

Edited by VAC
Posted (edited)

Modified from here. If you select field data text it will redraw entity to be dashed until you regen.

 

;;----------------------------------------------------------------------;;
;;REDRAW ENTITY FROM FIELD DATA ID
(defun C:FieldEntity (/ att attlst handle id obj pt sp ep)
  (vl-load-com)
  (setq att (vla-fieldcode (setq obj (vlax-ename->vla-object (car (nentsel "\nSelect Text with field data: "))))))
  (setq attlst (sepnumbers att))
  (foreach str attlst
    (if (> (setq id (atoi str)) 0)
      (progn
        (setq handle (vla-get-handle (vla-objectidtoobject (vla-get-activedocument (vlax-get-acad-object)) id)))
        (setq ent (handent handle))
        (redraw ent 3)
      )
    )
  )  
)
;https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-separe-number-and-string-in-the-same-string/m-p/2806136/highlight/true#M292581
(defun sepnumbers (str / tmp char currIsNr lastWasNr rslt)
  (setq tmp "")
  (while (/= (setq char (substr str 1 1)) "")
    (setq currIsNr (wcmatch char "#"))
    (if (eq currIsNr lastWasNr)
      (setq tmp (strcat tmp char))
      (setq rslt (cons tmp rslt)
            lastWasNr currIsNr
            tmp char
      )
    )
    (setq str (substr str 2))
  )
  (setq rslt (reverse (cons tmp rslt)))
  (cond
    ((not rslt) '( ""))
    ((eq (car rslt) "") (cdr rslt))
    (T rslt)
  )
)

 

Edited by mhupp
added (vl-load-com)
Posted (edited)

When I run your script it shows error:

error: ActiveX server returns error: unknown name: FieldCode..........................................I translate it to english because I do not have ACAD in english, so it can be a little bit different

I run it, than try to click on an attribute with field and that happened. I try i in dynamic block and in the model space. Both the same result.

Maybe it is because I have field in attribute not in text. Or maybe it is because there are more objects in one field formula.

Field look like this (one line's lenght + second line lenght + third line lenght,....  = field formula). I have to find each used line.

How should I use it?

Edited by VAC
Posted (edited)

You mind posting what the filed data looks like?

should look something like this

%<\AcObjProp Object(%<\_ObjId 1399071760>%).Area>%

 

--edit

is the text your selecting have a hatch around it like this?

image.png.3b21afe415c34679196c7564f0be2eca.png

Edited by mhupp
Posted (edited)
4 hours ago, VAC said:

Maybe it is because I have field in attribute not in text.

 

That could be it. try this lisp where you manually input the objectID manually.

 

;;----------------------------------------------------------------------;;
;;REDRAW ENTITY FROM OBJECT ID
(defun C:ObjectID (/ id handle ent)
  (vl-load-com)
  (setq id (atoi (getstring "\nEnter ObjectID: ")))
  (setq handle (vla-get-handle (vla-objectidtoobject (vla-get-activedocument (vlax-get-acad-object)) id)))
  (setq ent (handent handle))
  (redraw ent 3)
)

 

Edited by mhupp
Posted

I have tried the second lisp, but:

Enter ObjectID:

I entered: 1731241228992
-> ; error: Automation error. Description not available.

 

I attached sample file. There is one sample block with 4 circles and 1 attribute with field in it. It reads parameters only from the first circle (blue) and from the circle A (green) and one horizontal line across the circle A (yellow). Other grey entities are unused. You can try your lisps on it. I want to run the lisp (in the block editor or in model space), click on the attribute and highlight blue, green and yellow entities.

find_entity_in_field.dwg

Many thanks.

Posted

Use this on the 0,500 text will display the correct ID's

 

(gc:FieldCode (car (nentsel)))
Select entity: "%<\\AcExpr ((-(%<\\AcObjProp.16.2 Object(%<\\_ObjId 1449037232 0>%,1).Center \\f \"%lu2%pt1%pr2\">%)*sin(%<\\AcObjProp.16.2 Object(%<\\_ObjId 1449034288 0>%,1).Angle \\f \"%au0%pr2\">%)+(%<\\AcObjProp.16.2 Object(%<\\_ObjId 1449037232 0>%,1).Center \\f \"%lu2%pt2%pr2\">%)*cos(%<\\AcObjProp.16.2 Object(%<\\_ObjId 1449034288 0>%,1).Angle \\f \"%au0%pr2\">%))/1000-(-(%<\\AcObjProp.16.2 Object(%<\\_ObjId 1449037040 0>%,1).Center \\f \"%lu2%pt1%pr2\">%)*sin(%<\\AcObjProp.16.2 Object(%<\\_ObjId 1449034288 0>%,1).Angle \\f \"%au0%pr2\">%)+(%<\\AcObjProp.16.2 Object(%<\\_ObjId 1449037040 0>%,1).Center \\f \"%lu2%pt2%pr2\">%)*cos(%<\\AcObjProp.16.2 Object(%<\\_ObjId 1449034288 0>%,1).Angle \\f \"%au0%pr2\">%))/1000) \\f \"%lu2%pr3%ds44\">%"

 

Updated ObjectID lisp to draw them in model space. remember what ever the block is scaled to you need to scale them to from 0,0,0

 

Posted (edited)

Lee Mac's Field Objects lisp http://lee-mac.com/fieldobjects.html 

This program enables the user to easily view the object or set of objects referenced by a selected Field.

Upon issuing the command syntax fieldobjects at the AutoCAD command-line, the program will prompt the user to select an annotation object (Text, MText or Attribute) containing one or more field expressions referencing one or more objects in the active drawing. Such fields may be created using my Areas to Field program, or my Area Field to Attribute program.

Following a valid selection, the program will enclose the selected annotation object containing the field(s) with a green rectangular text box, with links to every referenced object, each of which is surrounded by a red rectangular bounding box. The size of the rectangular frames relative to the enclosed objects is dependent on the current zoom level, and will automatically update as the user zooms & pans around the drawing area.

 

I added this macro years ago to my Text, Mtext, Field drop-down

^C^C^P(or C:FieldObjects (load "FieldObjectsV1-0.lsp"));FieldObjects

Great when you need it, thanks Lee!

Edited by tombu
  • Like 1

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