resullins Posted March 18, 2021 Posted March 18, 2021 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! Quote
BIGAL Posted March 19, 2021 Posted March 19, 2021 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) 1 Quote
steven-g Posted March 19, 2021 Posted March 19, 2021 You need to use a dynamic block for this to work (without Lisp ). 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. 1 Quote
resullins Posted March 19, 2021 Author Posted March 19, 2021 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 Quote
steven-g Posted March 19, 2021 Posted March 19, 2021 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 Quote
resullins Posted March 19, 2021 Author Posted March 19, 2021 Nope... tried that. Switched it back and forth a few times. Ran REGEN... stays at "---" Quote
steven-g Posted March 19, 2021 Posted March 19, 2021 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 Quote
resullins Posted March 19, 2021 Author Posted March 19, 2021 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. Quote
steven-g Posted March 19, 2021 Posted March 19, 2021 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 Quote
resullins Posted March 19, 2021 Author Posted March 19, 2021 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! Quote
steven-g Posted March 19, 2021 Posted March 19, 2021 HaHa Got it. Simple when you know how You need to tick the box to show values for the block reference. 1 Quote
resullins Posted March 19, 2021 Author Posted March 19, 2021 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? Quote
steven-g Posted March 19, 2021 Posted March 19, 2021 Yeah worked straight away. _CG_FLAG (1).dwg 2 Quote
resullins Posted March 19, 2021 Author Posted March 19, 2021 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... 1 Quote
Recommended Posts
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.