Automatic Concatenation of Block Attributes

Automatic Concatenation of Block Attributes

arkelec
Collaborator Collaborator
5,236 Views
9 Replies
Message 1 of 10

Automatic Concatenation of Block Attributes

arkelec
Collaborator
Collaborator

I'm not sure this is actually possible but here goes:

 

 

I have a block with 5 attributes in the format......

 

ATTR_01

ATTR_02

ATTR_03

ATTR_04

ATTR_05

 

Is is possible to add another attribute which will automatically concatenate the previous five attribute fields into the format 01.02.03.04.05

 

I have created a block which does this & added an attribute which references the first five but it doesn't update.  At all.

 

Could LISP be used to update the 6th attribute?

 

Block attached below.

0 Likes
Accepted solutions (1)
5,237 Views
9 Replies
Replies (9)
Message 2 of 10

ВeekeeCZ
Consultant
Consultant
Accepted solution

You need to work with a block reference, not a definition. Insert the block into drawing first - then edit the attribute, make fields.

Message 3 of 10

arkelec
Collaborator
Collaborator

Thanks @ВeekeeCZ, I see how that works now.

 

0 Likes
Message 4 of 10

ВeekeeCZ
Consultant
Consultant

Hi, as I've learned in THIS thread, you can use your approach as well, but the block has to be a dynamic. It does not work right away after the insertion - you need to change the block's geometry using this dynamic feature, then the block became a dynamic and... fields start working.

 

See the SCREENCAST

Message 5 of 10

mcahill
Explorer
Explorer

Hi,

 

This is exactly what I am trying to achieve in our title block template.

 

Could you please do a step by step for doing this in a title sheet template.

 

Example

 

Job no. = 17000

Stage = AP

Dwg no, = 0100

(Inserted text - REV (Constant))

Revision = A

 

Required Drawing no. string. = 17000-AP-0100-REV-A

0 Likes
Message 6 of 10

ВeekeeCZ
Consultant
Consultant

I would think that the screencapture is very much understandable. Did you try it? Where did you get hit the wall?

BTW You did not post your block... not sure that you can (no privilege since you're new), if you cannot, post it elsewhere on other cloud and post here just a link.. 

Message 7 of 10

mcahill
Explorer
Explorer

Hi BeeKeeCZ,

 

 

Thanks for your response.

 

 

I'm not familiar with dynamic blocks. I have followed your screen cast and my block seems to work now.

 

I had to re-scale my title block as the process made it tiny. (Probably something to do with the move point/parameter)

 

I've attached my work in progress block which I hope makes scene of what I have done to date.

 

Thank you so much for the tutorial, as I've been struggling with this for days.

 

Any comments/feedback on my block would be greatly appreciated.

 

 

 

 

0 Likes
Message 8 of 10

ВeekeeCZ
Consultant
Consultant

Glad that works for you.

 

I would suggest to put the (trigger) point somewhere else then on 0,0,0 which became the insertion point and its never good to you have 2 points on the same spot.

Message 9 of 10

OliverE
Advocate
Advocate

Old thread but....once you add the dynamic feature, do you need to adjust the dynamic feature each time you want the attributes to update or does it happen automatically after you've adjusted the dynamic feature the first time?

 

Also, any idea how to have similar functionality but for two different blocks, ie have a field attribute in Block1 update by reading Block2's information? I have Block1 as a Label Block and Block2 as a Callout Block in SSM. Once I've inserted the Callout Block, I'd like the Label Block to display what sheet the Callout Block is inserted on. I've inserted both blocks and have tried to select the Label Block's attribute then right clicking -> Insert Field -> Object -> Select Object. But once the select object cursor appears, I cannot change layouts or space to select the Callout Block. If they're on the same sheet I can get it to work but I need the Callouts and Labels on different sheets.

 

Thanks

 

C3D2021, Windows 10

0 Likes
Message 10 of 10

Sea-Haven
Mentor
Mentor

Maybe some thing like this. Its not working not sure why not, maybe its my Bricscad. Big thanks to Lee-mac for  Layout Field | Lee Mac Programming (lee-mac.com)

(defun c:test ( / lay layname x)
(if (= (getvar 'ctab) "Model") (progn (alert "program only starts in a layout \nWill now exit \nplease go to a layout ")(exit)))

(vlax-for lay (vla-get-Layouts (vla-get-activedocument (vlax-get-acad-object)))
(setq layname  (vlax-get lay 'name))
(if (= layname (getvar 'ctab))
(princ (setq idnum  (itoa (vla-get-objectid lay))))
)
)
; big help from Lee-mac
; https://lee-mac.com/layoutfield.html
(setq str
(strcat
"%<\\AcObjProp Object(%<\\_ObjId "
idnum
">%).TabOrder>%"
)
)

(setvar 'ctab "Model")

; insert block with no attribute values
(setvar 'attreq 0)
(command "-insert" "aaa" (getpoint "\npick point ") 1 1 0)

; update attribute string to a field
(setq obj (vlax-ename->vla-object (entlast)))
(setq atts (vlax-invoke obj 'Getattributes))
(setq att (car atts))
(vlax-put att 'textstring str)

(princ)
)

Maybe some can see what is wrong. Just made a block with 1 attribute called "aaa" for testing. Getting #### as result.

0 Likes