.NET

Reply
*Expert Elite*
chiefbraincloud
Posts: 753
Registered: ‎02-13-2008
Message 11 of 48 (389 Views)

Re: Overrule a specific subentity in block and not showing the Base.

08-14-2012 11:47 PM in reply to: JanetDavidson

A couple more things, for Janet:

 

My block that I am overruling contains some 3D Solid geometry (3 extruded regions), several lines, and exactly 4 invisible attributes.  I honestly can not believe that the contents of the block can have any bearing on the function of the overrule.

 

And also I have not tried copying the block, (I think I covered the problems I was seeing with Regen and Select).  What problem have you seen specific to copying the block?

 

For what it is worth, I opened your sample drawing, selected the block, and I don't see grips for your attributes.  I exploded things, to make sure it wasn't a nested block, and I checked properties of the exploded Attribute Definitions, and I can't come up with a valid reason for that.  Any insight?

Dave O.                                                                  Sig-Logos32.png
Valued Mentor
jeff
Posts: 331
Registered: ‎05-12-2009
Message 12 of 48 (375 Views)

Re: Overrule a specific subentity in block and not showing the Base.

08-15-2012 02:11 AM in reply to: chiefbraincloud

My post screwed up and not much time but real quick I am getting a little confused.

 

Started a similar thread on subject http://www.theswamp.org/index.php?topic=42487.0

 

I could be completely wrong here bur,

 

A AttributeReference is created for each BlockReference so would be easier to just overrule AttributeReference. If you add Xdata to the AttributeDefinition then it will be cloned with the new AttributeReference and you can just have a DrawableOverriule for AttributeReference with a Xdata filter

 

When WorldDraw() is called on a BlockReference it uses the BlockReference to create a Transformation matrix and pushes it on Transform stack, then it calls Draw() on its BlockTableRecord which draws all the entities in definition, then pops the matrix off stack.

 

 

So if have a DrawableOverrule for BlockReferences and are overriding the WorldDraw() method

and you call base.WorldDraw()

you just told it to

1. Get the transformation, scale, rotation, etc... from the blockreference and send it to the graphics pipeline which will apply that to each entities model coordinates.

2. Call Draw() on the BlockTableRecord of the Reference which calls WorldDraw() on each entity in the BlockTableRecord, which will have the transformation matrix applied to it.

3. Remove the Transformation matrix from graphics pipeline.

 

More to it but in simple terms you can think a BlockReferences WorldDraw() just knows how to apply a transformation matrix to be applied for each entity in definition.

 

 

For returning true of false from WorldDraw(),

 

Basiclly what happens is

 

Drawable.SetAttributes()

 

If Drawable.WorldDraw() = False

 

For each Viewport

Drawable.ViewPortDraw

 

End If

 

Whatever you do WorldDraw is for every viewport.

 

If you return true ViewportDraw is not called but if false the ViewPortDraw is called for each Viewport.

Could show different geometry for TOP and BOTTOM view, etc... and whatever needs to be shared would be drawn in WorldDraw.

 

Different ways not sure which way is best but could have Xdata attached lines inside definition.

 

You could inside your BlockReference WorldDraw add a overrule for overruling entites in definition, then call the base.WorldDraw() then remove the Overrule and retuen true or false.

 

 

 

 

You can also find your answers @ TheSwamp
Distinguished Contributor
JanetDavidson
Posts: 139
Registered: ‎08-23-2011
Message 13 of 48 (364 Views)

Re: Overrule a specific subentity in block and not showing the Base.

08-15-2012 05:28 AM in reply to: chiefbraincloud

 

And also I have not tried copying the block, (I think I covered the problems I was seeing with Regen and Select).  What problem have you seen specific to copying the block? The Copied Block Disappears

 

For what it is worth, I opened your sample drawing, selected the block, and I don't see grips for your attributes.  I exploded things, to make sure it wasn't a nested block, and I checked properties of the exploded Attribute Definitions, and I can't come up with a valid reason for that.  Any insight?  I didn't want user to see Attribute Grip.


 

Distinguished Contributor
JanetDavidson
Posts: 139
Registered: ‎08-23-2011
Message 14 of 48 (362 Views)

Re: Overrule a specific subentity in block and not showing the Base.

08-15-2012 05:58 AM in reply to: chiefbraincloud

Here is the Spec:

HP - QuadCore - i 5 - 3 GigHz - Win 7 64 - Autocad 2012 64 -  8 GiG Ram - and NVidia nv300 .

 

My code and My block works findeif I leave  this line :

MyBase.WorldDraw(drawable, Wd)

But If I remove the line

MyBase.WorldDraw(drawable, Wd)

 

Then it will do exactly what you mentioned .

Janet.

 

Board Manager
StephenPreston
Posts: 400
Registered: ‎05-22-2006
Message 15 of 48 (351 Views)

Re: Overrule a specific subentity in block and not showing the Base.

08-15-2012 09:56 AM in reply to: chiefbraincloud

CBC: Quick question - When you have these display problems, are you using a 3D shademode? Do you see the same problems in 2D wireframe also?

 

I ask because 3D shademodes use a different graphics pipeline that caches graphics to optimize performance. There's extra work needed to support that when overruling a block reference, which (as I recall)  I didn't do in DigSigStamp.

 

 

Cheers,

Stephen Preston
Autodesk Developer Network
*Expert Elite*
chiefbraincloud
Posts: 753
Registered: ‎02-13-2008
Message 16 of 48 (347 Views)

Re: Overrule a specific subentity in block and not showing the Base.

08-15-2012 10:21 AM in reply to: StephenPreston

I have not been in a shade mode, I have been using 2d Wireframe.  So far today, still no progress.  Updating Video driver did not help.  Testing my code in your example drawing did not help.  The NVidea AutoCAD Performance Driver indicates that it is for 2009, 2010, and 2011, no mention of 2012, so I don't think that is going to help.

 

I'm getting ready to try it out on some other machines now.

Dave O.                                                                  Sig-Logos32.png
Board Manager
StephenPreston
Posts: 400
Registered: ‎05-22-2006
Message 17 of 48 (336 Views)

Re: Overrule a specific subentity in block and not showing the Base.

08-15-2012 01:50 PM in reply to: JanetDavidson

Janet,

 

(While I'm trying to reproduce the weirdness that CBC and you describe ... my DigSigStamp sample is working fine for me) ...

 

If I were selectively drawing the entities in a BlockTableRecord as you are doing, I wouldn't be exploding the BlockReference, calling WorldDraw on the resultant entities and then disposing all the entities. Instead, I'd iterate through the entities in the BlockTableRecord that the BlockReference represents, and call Geometry.Draw(entity) on each entity I wanted to display.

 

If you read the reference guide documentation for Geometry.Draw, you'll see that this is how a BlockReference actually draws itself. You can use Geometry.Draw() when you want to draw something that has a lifetime that spans at least the lifetime of the graphics cache (like the contents of a BlockTableRecord). Never use it with temporary entities you plan to dispose as soon as you've used them.

 

And if you want your overrule to work correctly in a 3D shademode, you have to also overrule at least ViewportDrawLogicalFlags as well. I believe my bonus sample for the My First AutoCAD Plugin tutorial demonstrates that (you can find that on www.autodesk.com/developautocad).

 

And of course, if the blocks you want to customize are your own, then it would probably be a lot simpler to use the dynamic blocks feature instead if they can achieve what you need. You're right that overrules are complicated - to overrule an entity, you have to know a lot of the concepts required to create a custom entity using ObjectARX. That's probably the most complicated API AutoCAD exposes.

 

HTH.

Cheers,

Stephen Preston
Autodesk Developer Network
Distinguished Contributor
JanetDavidson
Posts: 139
Registered: ‎08-23-2011
Message 18 of 48 (314 Views)

Re: Overrule a specific subentity in block and not showing the Base.

08-15-2012 07:46 PM in reply to: StephenPreston

Stephen and Chief,

Thanks for your time to look into my  problem. 

Stephen

The blocks in real scenario  are dynamic blocks and more  complicated than the one I attached . I just  tried to present the  problem in an easy way so people bother to look into it. We don't need them to work in 3D Shades Mode ,  in our company, Thanks God. 

I tried hard to digest your DigSigStamp but it is complicated.

It would be nice of you  if you do all of us in this discussion group  a favor and

convert  my  code in a classic and proper way(Geometry .Draw ) to work with the block I attached.

I am pretty sure converting my simple code would be piece a cake for you.

I just need the line to be seen as a  circle , and everything else disappear.

Hope your skills and knowledge  help us to understand this overrule by simple samples like this rather than complicated

terminology in documents .

Cheers and Thanks

Janet.

 

 

Valued Mentor
DiningPhilosopher
Posts: 370
Registered: ‎05-06-2012
Message 19 of 48 (305 Views)

Re: Overrule a specific subentity in block and not showing the Base.

08-16-2012 01:40 AM in reply to: StephenPreston

StephenPreston wrote:

 

If you read the reference guide documentation for Geometry.Draw, you'll see that this is how a BlockReference actually draws itself. You can use Geometry.Draw() when you want to draw something that has a lifetime that spans at least the lifetime of the graphics cache (like the contents of a BlockTableRecord). Never use it with temporary entities you plan to dispose as soon as you've used them.

 


Hi. I don't seem to have any problem with drawing temporary entities and disposing them right away. Their graphics belong to the Drawable that's passed into the WorldDraw call, rather than to entities passed to Geometry.Draw().

 

For example, here's some code I was just toying with, that customizes the text of entities nested in blocks, notice that I clone the original text, modify it, and then dispose the clone after drawing it. I don't have any problems with this code.

 

   public class NestedTextDrawOverrule : NestedDrawableOverrule<DBText>
   {
      protected override bool WorldDraw( DBText text, WorldDraw wd )
      {
         BlockReference outerMost = this.OuterMostContainer;
         if( outerMost != null && text.Database != null )
         {
            using( DBText surrogate = (DBText) text.Clone() )
            {
               surrogate.TextString = outerMost.Name;
               surrogate.AdjustAlignment( text.Database );
               wd.Geometry.Draw( surrogate );
               return true;
            }
         }
         return base.WorldDraw( text, wd );
      }
   }

 

Valued Mentor
jeff
Posts: 331
Registered: ‎05-12-2009
Message 20 of 48 (290 Views)

Re: Overrule a specific subentity in block and not showing the Base.

08-16-2012 08:46 AM in reply to: DiningPhilosopher

When I get a little time later will post code but I am having issues also.

You can also find your answers @ TheSwamp
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.