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.
Solved! Go to Solution.
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.
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 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.
Start with some of our most frequented solutions to get help installing your software.