Author Topic: Keeping attribute rotation 0 and persistent  (Read 3137 times)

0 Members and 1 Guest are viewing this topic.

Jeff H

  • Needs a day job
  • Posts: 6144
Keeping attribute rotation 0 and persistent
« on: August 13, 2012, 06:47:28 PM »
The main idea used has been covered here, but here is the functionality needed and have heard of people doing it in Lisp but I get scared and confused after the 5th or 6th paraenthess.

Thanks to Stephan and gile in link above for using their ideas
 
Maybe the best way would be to explain the end result and the way I thought about going about it and probably a way through the UI as MEP offers it.
 
 
Trying to provide the same functionality that MEP does for text in blocks used for views by checking "Keep text horizantol while rotating" for inserting blocks with text for Vanilla AutoCAD. So I do not care if it is text, attribute, or ploylines as long as it does bloat drawing, but I guess to point out it in the end it is just text and does not need any functionality that attributes offer, but seemed easier to use for intial idea.
 
I need it to be persistent in-house. Once it leaves our hands and as long as they are rotated correctly when a drawing is opened the very first time is all it needs. Once opened outside of office all bets are off and if they rotate the blocks then they can manually rotate the attributes themselves.
So basiclly the rotation set before an Save.
 
To put in easiest form possible "I want to insert blocks with text and the text stay right side up when rotated so it is readable. I could use attributes but have to manully rotate them and could use text seperate from block but would be nice if they were together(just made me think of a group).
A receptacle symbol with GFI text would be a good example of one used.
 
So my intial idea was let the user decide which ones to keep horizontol by running a command while defining block or editting in block editor by selecting an AttributeDefinition. All the command does is attached some Xdata.
 
To cover all the bases, like grip editing I could do a drawable overrule for AttributeReferences with Xdata filter.
 
To keep it persistent in the Database.BeginSave Event add a ObjectOverrule with same xdata filter and update objects in open override to match state, and then in  the Database.SaveComplete Event I could remove the ObjectOverrule.
 
 
Any ideas or comments.
The end result is just inserting blocks with text(not going to say

TheMaster

  • Guest
Re: Keeping attribute rotation 0 and persistent
« Reply #1 on: August 14, 2012, 04:42:57 PM »
Heads-up text and attributes are very different, since TEXT are not attached to each block reference, and the only way to make TEXT always heads-up is to do the drawing of the block insertions yourself, which is fairly complicated.

Basically, you would have a DrawableOverrule on BlockReference, and another one on TEXT. When the WorldDraw() or ViewportDraw() for a block reference is called, you can setup a stack that tells the TEXT DrawableOverrule what block reference(s) the text is nested in, and store the transformation you need to draw the text heads-up.  I think I touched on that in another thread (using a stack holding the BlockReferences whose WorldDraw() or ViewportDraw() functions are in progress).

Since  WorldDraw/ViewportDraw calls for block entities are nested within calls to those methods for their container block references, you can maintain a stack of the containers to tell if TEXT objects they contain are being drawn, and use it to decide if the orientation of the text needs to be changed.

That's about the only way I can think of to do it without converting the text to attributes, and of course, it's dependent on your code being loaded.

Jeff H

  • Needs a day job
  • Posts: 6144
Re: Keeping attribute rotation 0 and persistent
« Reply #2 on: April 16, 2013, 03:47:25 AM »
Not a big deal and just out of curiosity,
Instead of interacting directly with DBText or Mtext would it be easier to create a BlockTableRecord containing the text and insert a BlockReference into the original BlockTableRecord.
Maybe use xdata or ExtensionDictionaries as a filter and to differentiate between the owner BlockReference and text BlockReference .
 
Then when WorldDraw is called on original BlockReference store the rotation to calculate what modifications to make to matrix for next WorldDraw called for the text's blockreference?
 
If that makes any sense.

TheMaster

  • Guest
Re: Keeping attribute rotation 0 and persistent
« Reply #3 on: April 16, 2013, 08:13:13 AM »
Not a big deal and just out of curiosity,
Instead of interacting directly with DBText or Mtext would it be easier to create a BlockTableRecord containing the text and insert a BlockReference into the original BlockTableRecord.
Maybe use xdata or ExtensionDictionaries as a filter and to differentiate between the owner BlockReference and text BlockReference .
 
Then when WorldDraw is called on original BlockReference store the rotation to calculate what modifications to make to matrix for next WorldDraw called for the text's blockreference?
 
If that makes any sense.

Hi Jeff.  If you put the text into a Block then you can deal with the block reference's orientation rather than having to deal with text and figure out what container block references it's inserted into. The only concern I have with using DrawableOverrules is that nothing is persistent and requires the overrule to be loaded in order for the behavior to exist. That can be pretty confusing to the user if they don't realize that the text they see is actually not going to look that way when they open the file in LT or some other software that reads DWG files.

Jeff H

  • Needs a day job
  • Posts: 6144
Re: Keeping attribute rotation 0 and persistent
« Reply #4 on: April 17, 2013, 10:43:35 PM »
Thanks Tony,
 
I think I will go with adding a rotation parameter to text and automatically set value so when sent to clients all existing BlockReferences will look the same and if the rotate one they will just have to manually rotate text.