Jump to content

Recommended Posts

Posted

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.

Posted

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.

 

 

Posted

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

Posted

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 ?

Posted

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.

 

Posted (edited)

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 (entsel "\nPick dimension "))))
(vlax-put obj 'textoverride str)
(command "regen")

(princ)
)

 

Edited by BIGAL
Posted

Thank you very much Bigal! Works super! I could even put the chosen attribute into a block as a field.

Posted

By the way, and I hope I'm not pushing it. Is there a way to put in commas between the attributes? Thanks again!

Posted (edited)

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 'textoverride str)
(command "regen")
(princ)
)
(c:wow)

 

Edited by BIGAL
Posted

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

Posted (edited)

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
Posted

Thanks for replying! I will try and post it at the other forum as well.

Posted
;; Get ObjectId and create fielexpression
            (setq objid (vla-get-ObjectId (vlax-ename->vla-object ent)))
            (setq fldexp (strcat "%<\\AcObjProp Object(%<\\_ObjId " (itoa objid) ">%).TextString>%"))

 

I found the part of a code above. And I'm wondering if it somehow could be used in this section of the code?

 

Skrmbild2024-10-18134645.thumb.jpg.693da6d9f685d92a67dd1485c536fdcd.jpg

 

Posted

The problem is not in the code but rather that a dimension does not update when the attribute is changed. Only way around it is to use a Mtext.

Posted

thanks again! That will be fine.

  • 1 month later...
Posted

Yes it does!

Thanks for your help!

 

Updated lisp:

 

(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 (entsel "\nPick dimension "))))
(vlax-put obj 'textoverride str)
(command "regen")
(princ)
)
(c:wow)

 

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