Jump to content

Dynamic blocks and attributes


Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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