.NET

Reply
Valued Contributor
RichardCammeray
Posts: 56
Registered: ‎12-08-2010
Message 1 of 4 (274 Views)
Accepted Solution

Overrule control in BlockReference

274 Views, 3 Replies
06-26-2012 09:35 PM

I am working on simple WorldDraw overrule where lines and polylines are displayed with little cross. Size of cross is related to view size.

Everything works fine except blocks and Xrefs. If they are scaled then crosses are scaled as well.

I know how to get entity owner ID but it refers to BlockTableRecord only not to BlockReference.

 

I think that  my problem doesn’t  have solution just I have little hope for some help.

 

Thanks

Richard


RichardCammeray wrote:
Can't believe but it works. I retrieve matrix from WorldToModelTransform and then matrix.GetScale(). This scale then I used to maintain correct size of vertex cross. If you can give me some other hints for two other points would be great:
1) I tried to filter out lines belongs to Xref by comparing entity.blockId with modelID but it compromises performance during REGEN. What is the best approach to do this with Overrule?
2) Sizes of vertex crosses are related to view size, so now after each zooming user has to use REGEN to update cross sizes. Is it possible to achieve this update without using REGEN What I love in .NET API that virtual box of knowing is endless :smileyhappy: Thank you for help. Richard.

1. I've not done much worlddrawing I'm afraid (because it creates a visual dependence on code which means the drawing cannot be faithfully reproduced if the custom worlddraw code is not installed and loaded - and that means you would not see the same drawing if you opened it in AutoCAD LT, or any other software that reads .DWG files).

 

I've not tried getting the containers of each entity being drawn. Of course, the way you've tried that will slow things to a crawl.  One possible way to do it, is to cache the IDs of the blockreferences passed into calls to WorldDraw() in a Stack<ObjectId>. Upon entry to your overrule's WorldDraw(), if the drawable passed in is a block reference, push it's ObjectId onto the stack. Then after supermessaging the DrawableOverrule base class, pop the id off the stack. From the WorldDraw() calls for all entities owned by the block, the ids of their container blockreferences should all be on that stack, with a reference to the owning block at the top, followed by any block references the owning block reference is nested in. That should work because the WorldDraw() calls for entities in a block are made from the WorldDraw() calls for references to the owning block, but even that will slow things down if you're checking every entity.

 

2. WorldDraw() calls are made when entities are regenerated, and the generated geometry is cached. Since most zooms don't require regeneration, they don't trigger calls to WorldDraw(), and if you've noticed, that same problem affects POINT entities when PDSIZE is negative - They are scalled when the view magnification changes, and a regen is needed to get them to update to the desired screen-relative size. 

Valued Mentor
DiningPhilosopher
Posts: 370
Registered: ‎05-06-2012
Message 2 of 4 (249 Views)

Re: Overrule control in BlockReference

06-27-2012 04:29 PM in reply to: RichardCammeray

Keep in mind that the entity passed into WorldDraw() can be a component part of a composite set of block references that can be nested to any depth. So, you shouldn't assume that the block reference containing the entity being drawn is inserted into model or paper space, it could be inserted in another block that is in-turn inserted into model or paper space.

 

The ModelToWorldTransform and WorldToModelTransform properties of the Geometry class (which is exposed as a property of the WorldDraw class that is passed into the WorldDraw() method) gives you the transformation to/from the entity being drawn and the top-level block insertion that entity is nested in.

 

You can use those properties in conjunction with the PushModelTransform() and PopModelTransform() methods to temporarily draw geometry in the entity coordionate system of the top-level block reference. 

Valued Contributor
RichardCammeray
Posts: 56
Registered: ‎12-08-2010
Message 3 of 4 (236 Views)

Re: Overrule control in BlockReference

06-27-2012 08:20 PM in reply to: DiningPhilosopher
Can't believe but it works. I retrieve matrix from WorldToModelTransform and then matrix.GetScale(). This scale then I used to maintain correct size of vertex cross. If you can give me some other hints for two other points would be great: 1) I tried to filter out lines belongs to Xref by comparing entity.blockId with modelID but it compromises performance during REGEN. What is the best approach to do this with Overrule? 2) Sizes of vertex crosses are related to view size, so now after each zooming user has to use REGEN to update cross sizes. Is it possible to achieve this update without using REGEN What I love in .NET API that virtual box of knowing is endless :smileyhappy: Thank you for help. Richard. This e-mail and any attachments contain URS Corporation confidential information that may be proprietary or privileged. If you receive this message in error or are not the intended recipient, you should not retain, distribute, disclose or use any of this information and you should destroy the e-mail and any attachments or copies.
Valued Mentor
DiningPhilosopher
Posts: 370
Registered: ‎05-06-2012
Message 4 of 4 (231 Views)

Re: Overrule control in BlockReference

06-27-2012 09:48 PM in reply to: RichardCammeray

RichardCammeray wrote:
Can't believe but it works. I retrieve matrix from WorldToModelTransform and then matrix.GetScale(). This scale then I used to maintain correct size of vertex cross. If you can give me some other hints for two other points would be great:
1) I tried to filter out lines belongs to Xref by comparing entity.blockId with modelID but it compromises performance during REGEN. What is the best approach to do this with Overrule?
2) Sizes of vertex crosses are related to view size, so now after each zooming user has to use REGEN to update cross sizes. Is it possible to achieve this update without using REGEN What I love in .NET API that virtual box of knowing is endless :smileyhappy: Thank you for help. Richard.

1. I've not done much worlddrawing I'm afraid (because it creates a visual dependence on code which means the drawing cannot be faithfully reproduced if the custom worlddraw code is not installed and loaded - and that means you would not see the same drawing if you opened it in AutoCAD LT, or any other software that reads .DWG files).

 

I've not tried getting the containers of each entity being drawn. Of course, the way you've tried that will slow things to a crawl.  One possible way to do it, is to cache the IDs of the blockreferences passed into calls to WorldDraw() in a Stack<ObjectId>. Upon entry to your overrule's WorldDraw(), if the drawable passed in is a block reference, push it's ObjectId onto the stack. Then after supermessaging the DrawableOverrule base class, pop the id off the stack. From the WorldDraw() calls for all entities owned by the block, the ids of their container blockreferences should all be on that stack, with a reference to the owning block at the top, followed by any block references the owning block reference is nested in. That should work because the WorldDraw() calls for entities in a block are made from the WorldDraw() calls for references to the owning block, but even that will slow things down if you're checking every entity.

 

2. WorldDraw() calls are made when entities are regenerated, and the generated geometry is cached. Since most zooms don't require regeneration, they don't trigger calls to WorldDraw(), and if you've noticed, that same problem affects POINT entities when PDSIZE is negative - They are scalled when the view magnification changes, and a regen is needed to get them to update to the desired screen-relative size. 

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!