tchwiesz Posted October 26, 2015 Posted October 26, 2015 I'm trying to develop a dynamic block that takes two attributes input from the user (lets call them "x" and "y") and then divides them by the distance ("dist") of a line within the block that may be stretched. Then the result of this formula ((x + y) / dist) is to be displayed as an M-TEXT within the block definition. The problem I'm experiencing is that no matter what I do I can't convey the value of the attributes to the M-TEXT within the block - It only shows their default values and there's nothing I can do to update it with the current attribute values for the block. In other words: Lets say my default values for "x" and "y" are "0" and "1", respectively. I then change the value of "x" to "10" and "y" to "20" on the instance of the block. My M-TEXT has a field in it that references a "formula", and the formula references object->value for both the x and y attributes: "x + y" as the formula. However instead of showing me "30", the block instead shows "1" as these were my default values. I've attached the file I'm working with as an example (although the fields are named differently than what's here). I've posted the question to AutoDesk's forums as well using a more true example of what I'm doing (I simplified it here because it's been difficult to explain what the problem is), so if you would like to read my other attempt at explaining the problem, check out: http://forums.autodesk.com/t5/autocad-2013-2014-2015-2016/value-of-attribute-doesn-t-show-up-when-used-within-formula/td-p/5878314 WIP.dwg Quote
Ski_Me Posted October 26, 2015 Posted October 26, 2015 You might try looking into a data extraction because that whats this sounds like. Could be a LISP routine as well. Quote
tchwiesz Posted October 26, 2015 Author Posted October 26, 2015 Unfortunately data extraction would not be very useful to us with this application. Maybe a lisp routine however I'd hope there was a way to do it all in-block (why does autocad even have a formula field input if this can't be done?) Really all I'm trying to do is take an attribute (input from user), do a little math to it and display it in an M-TEXT. Quote
Ski_Me Posted October 26, 2015 Posted October 26, 2015 I'm not sure but blocks dynamic or otherwise wont perform functions other than what you can program from the block editor. Every block starts out as a normal everyday run of the mill block then you can add different things to them to make them perform in different ways but it's limited to what you have available in the block editor. Think of blocks in this way they represent a device or function that contributes to the summed output but don't represent the output. I know that doesn't help but I think your trying to make autocad do something that it was never intended to do. At least not in the way your trying to do it. But there very well may be somebody here that has done this despite what I say. Quote
steven-g Posted October 26, 2015 Posted October 26, 2015 The tricky bit will be Mtext. Mtext and attributes inside a block don't play nicely together. In the attached dwg is a block that uses just attributes, see if this approaches what you are wanting to do. You could also take a look at this other thread that had a similar question Grading Slope.dwg Quote
tchwiesz Posted October 26, 2015 Author Posted October 26, 2015 How on earth did you get that to work? I tried using attributes as well but was coming up empty... Quote
steven-g Posted October 26, 2015 Posted October 26, 2015 It actually isn't very straight forward, the attributes have to have a value (the value can't be left blank in the block definition). And once inserted you have to perform a dynamic action on the block and do a regen before the value will update. Quote
tchwiesz Posted October 26, 2015 Author Posted October 26, 2015 I can't seem to recreate your success. Can you take a look at the attached file and tell me what I'm not doing correctly? WIP-NEW.dwg Quote
steven-g Posted October 26, 2015 Posted October 26, 2015 Try changing the property of the "slope" attribute to preset=yes, if you enter a value when prompted it will overwrite the formula. EDIT the other attributes are OK with preset=no Quote
tchwiesz Posted October 26, 2015 Author Posted October 26, 2015 It works! Amazing, man! Thanks so much 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.