Jump to content

Recommended Posts

Posted

Morning Boys and girls. I have a block... pretty simple, where I want one of the attributes to appear twice. Basically, you enter it once and it updates in two places. I KNOW for a fact I've done this before with a field. But I'm attempting it again, and I can't get it to work. It's not updating. I currently have it set to an Object's value. And when I insert it it will take the initial value of the attribute (or default value), but won't update itself when I change the value. FIELDEVAL is set to 31. I'm sure I just have the wrong FIELD settings. 

 

Could someone smack the right answer into me please? Thanks! 

 

image.thumb.png.8ca35dc69c036df2a6d8eb06f24f9b1a.png

Posted

pretty sure problem is when do second attribute you have to reset the field being copied to the current attribute in the current block. So block has field1id same block inserted again has field2 id.

 

This is not your solution but was a solution for the problem of two atts. It adds attributes and displays in last attribute so change any att value and sum changes.

 

(defun c:test ( / obj lst x str)
(setq oldatt (getvar 'attdia))
(setvar 'attdia 0)
(command "-insert" "test" (getpoint "\npick point") 1 1 0 (getstring "\nEnter Att1 ") (getstring "\nEnter Att2 ") (getstring "\nEnter Att3 ") "-")
(setq obj (vlax-ename->vla-object (entlast)))
(setq lst '())
(foreach att (vlax-invoke obj 'getattributes)
(princ  "\n")
(setq lst (cons  (strcat "%<\\AcObjProp Object(%<\\_ObjId " 
(vlax-invoke-method (vla-get-Utility  (vla-get-activedocument (vlax-get-acad-object))) 'GetObjectIdString att :vlax-false)
">%).Textstring>%"
 ) lst ))
)
(setq str nil)
(setq x (length lst))
(setq str (strcat "%<\\AcExpr ("
(nth (setq  x (- x 1)) lst) "+"
(nth (setq  x (- x 1)) lst) "+"
(nth (setq  x (- x 1)) lst) ")>%"
)
)
(setq x 1 y 4)
(foreach att(vlax-invoke obj 'getattributes)
(if (= x y)
(Vla-put-textstring att str)
)
(setq x (+ x 1))
)
(setvar 'attdia oldatt)
(princ)
)
(c:test)

 

  • Like 1
Posted

You need to use a dynamic block for this to work (without Lisp :thumbsup: ).

It doesn't matter what dynamic action you use, any will do, I usually make use of a visibility state with 2 states (make sure everything is visible in both states). The problem is when you insert the block the first attribute is fine, but the field in the second attribute (which you should make sure is set to 'preset' in the properties) will try and copy the contents of the first attribute but will use the value contained in the 'block description' (The default value). If you make a change to a dynamic action, then the block becomes an annonymous block and the second attribute will now read the value from the inserted block and not the block description default value. You will need to regen for any changes to show up in the field.

It would be best to recreate your block from scratch, but if you do just edit the existing block then you will need to run the 'attsync' command.

  • Like 1
Posted

Ok, so I do have to do this without a LISP, as most of our users are on LT. So I whipped up a new version of the block quickly, but for the love of all that is holy I can't get it to work. 

 

I drew the geometry, blocked it and opened in BEditor, added my 6 attributes, with the last having a FIELD pointing to one of the others. FLAG_ID2 is preset. I added a dynamic property, saved it, and then inserted the block into a clean drawing. 

 

I also just realized I REALLY need to restart my computer, so I'm going to do that, but in the meantime, I'm gonna post my block here... and if someone could take a look, that would be SUPER helpful before I burn it all down. _CG_FLAG.dwg

Posted

I'm just taking a look, but you do have to activate the block by changing the dynamic action just once, and then it should start working (just inserting isn't enough). With a regen of course

Posted

Nope... tried that. Switched it back and forth a few times. Ran REGEN... stays at "---"

Posted

Yeah I see it, this is driving me nuts. I have cut your block down to just the two attributes, I created a a new block myself in the drawing which works just fine but yours won't play nicely, I'm trying to find what the differences are??? Here it is attached I have butchered your block a bit, changed tag names and text style to try and figure out why it won't work. But as you can see the one I made placed next to it works just fine. But there is something in your block stopping it from performing as expected.

 

_CG_FLAG(1).dwg

Posted

 

27 minutes ago, steven-g said:

Yeah I see it, this is driving me nuts. I have cut your block down to just the two attributes, I created a a new block myself in the drawing which works just fine but yours won't play nicely, I'm trying to find what the differences are??? Here it is attached I have butchered your block a bit, changed tag names and text style to try and figure out why it won't work. But as you can see the one I made placed next to it works just fine. But there is something in your block stopping it from performing as expected.

 

_CG_FLAG(1).dwg 77.07 kB · 0 downloads

 

See, that's what I was afraid of! What in the d*** hell?!?!?! I KNEW I had done this before and it didn't give me so many problems! I also did a bunch of research on this, found a dude that made his work EXACTLY like I want mine to, copied his attributes into my block, and they stopped working. I am freaking STUMPED. 

 

I'm gonna try starting from yours, build each piece and test until it doesn't work anymore. This is gonna give me a freaking STROKE. 

Posted

Me too. I have added the same two attributes that I use in my block, deleted your visibility parameter and created a new one. And it still won't work 🤯

Posted
28 minutes ago, steven-g said:

Me too. I have added the same two attributes that I use in my block, deleted your visibility parameter and created a new one. And it still won't work 🤯

 

So far, I've gotten as far as moving some stuff around, correcting layers, and making the block annotative... and it still works. This is the most boring troubleshooting I've ever done. HA! 

Posted

HaHa Got it. Simple when you know how :thumbsup:🤣 You need to tick the box to show values for the block reference.

 

CopyAttribute.jpg

  • Like 1
Posted

I saw that first thing and went back to my block, broke it down and added an attribute with that checked... and it still didn't work. Did you get it to on my block?

Posted

Ok... that one works. I think mine had a poltergeist. Seriously. WTF mate? 

 

Thank you for your help! Seriously appreciated. Such a simple block shouldn't have taken two people and this much conversation... 

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