Jump to content

Create field from attribute in block and put it directly into dimension.


fromMlm

Recommended Posts

Hi all,
Again I have found a lisp Lee Mac made that copies a field into a dimension, "copyfield", but it requires that the field already exists...

So is there a way to create a field from an attribute in a block and then insert the field directly into a dimension?

Thanks in advance.

Link to comment
Share on other sites

You can do a dimension then update the dimension string with a field just double click the dimension and a field is an option. In image move corner point and dim updates both normal length and area.

 

image.png.ccdbeed18711a80ff728ca3fb1a3333d.png

 

You need to explain more what is in the field, then could speed up the process with a lisp.

 

 

Link to comment
Share on other sites

Thanks for your answer!

I have rebar block with a rebar number called "Littera". I would be great if I could place that directly into the dimesnsion, which works as a marker for in what area the rebars are to be placed.

Can that also be done for multiple attributes into the same dimension?

Skrmbild2024-10-10090605.thumb.png.46e6160295e988d98cf6eac8c0345634.png

block.dwg

Link to comment
Share on other sites

In simple terms if you want say all attributes into the dim can be done by just using a text answer, it will not update. but you can run again.

 

For every time you want to do this using a field you have to get the ID of the attributes in the block selected, these are different for every block. Ok good news can be done, do you want the 25 12 s200 A326a as answer ?

Link to comment
Share on other sites

Thanks again Bigal for your reply!

 

The other attributes and "Littera" are for extraction to excel to sort them there.

What i was hoping for, was if one, two or more different "Littra" can be put into same dimension as field?


Skrmbild2024-10-11080818.png.33b3a5ec845a6e958acc51f92d16cc75.png

 

But multiple attributes as text answer into dimension from different blocks would be nice as well.

 

Link to comment
Share on other sites

Yes should be the answer, I have take 2 attributes add them together and put result into a 3rd attribute all as fields. Should be able to do pick pick etc 1 - ? then put in a dim.

 

Try this pick the attributes. Tested on 1 2 & 3 attributes.

 

; Take block atts and put as field in dimension
; By AlanH 2024

(defun c:wow ( / lst obj x str)
(setq lst '())

(while (setq ent (nentsel "\nPick a attribute Enter to stop "))
  (setq obj (vlax-ename->vla-object (car ent)))
  (setq lst (cons 
  (vlax-invoke-method (vla-get-Utility  (vla-get-activedocument (vlax-get-acad-object))) 'GetObjectIdString obj :vlax-false) lst ))
)

(setq lst (reverse lst))

(setq x -1 str "")

(repeat (length lst)
  (setq str (strcat str " " "%<\\AcObjProp Object(%<\\_ObjId " (nth (setq x (1+ x)) lst) ">%).Textstring>%"))
)

(setq obj (vlax-ename->vla-object (car (nentsel "\nPick dimension "))))
(vlax-put obj 'textstring str)
(command "regen")

(princ)
)

 

Edited by BIGAL
Link to comment
Share on other sites

Try this version

 

(defun c:wow ( / lst obj x str)
(setq lst '())

(while (setq ent (nentsel "\nPick a attribute Enter to stop "))
  (setq obj (vlax-ename->vla-object (car ent)))
  (setq lst (cons 
  (vlax-invoke-method (vla-get-Utility  (vla-get-activedocument (vlax-get-acad-object))) 'GetObjectIdString obj :vlax-false) lst ))
)

(setq lst (reverse lst))

(setq x -1 )
(setq  str  (strcat "%<\\AcObjProp Object(%<\\_ObjId " (nth (setq x (1+ x)) lst) ">%).Textstring>%"))
(if (> (length lst) 1)
 (repeat (- (length lst) 1)
  (setq str (strcat str ","  "%<\\AcObjProp Object(%<\\_ObjId " (nth (setq x (1+ x)) lst) ">%).Textstring>%"))
 )
)

(setq obj (vlax-ename->vla-object (car (nentsel "\nPick dimension "))))
(vlax-put obj 'textstring str)
(command "regen")
(princ)
)
(c:wow)

 

Link to comment
Share on other sites

Thanks!!

 

But it seems like something happend. When I update an attribute it won't change in the dimension. And when I go into the dimension the fields isn't there and it turns back to a plain dimension. What am I missing?


Skrmbild2024-10-13102855.thumb.png.62886166b00ebcad9a3ec37710dbb810.png

Link to comment
Share on other sites

You are right I changed the attribute value and the dim field did not update. I did the same to a mtext and it worked. It looks like you can not Update the dim value. May have to look at a dynamic block with a attribute.

 

Any body have an idea ?

 

Maybe ask over at forums/autodesk post link to here. 

 

Ok probably only way is make a dim block with also a Mtext value. Have the measurement set to blank eg space. insert it, align the dim and stretch etc, explode,  then code will work.

 

 

Edited by BIGAL
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...