Model space showing entity which are not sure how to tell visibility

Model space showing entity which are not sure how to tell visibility

Anonymous
Not applicable
1,050 Views
4 Replies
Message 1 of 5

Model space showing entity which are not sure how to tell visibility

Anonymous
Not applicable

I am using realDwg to fetch 2d shape form a dwg file.

 

I found I get too much geom which is not showing in the autoCAD.

 

I found the problem is that the BlockTableRecord contains too many useless BlockReferences.

Each one has its own entity of Curves and shapes.

 

Here is my code: 

foreach (ObjectId id in ms)
{

    Entity ent = (Entity)tr.GetObject(id, OpenMode.ForRead);

    //if entity is text polyline, or other stuff, just save them and show them in svg later

 

    if(ent is BlockReference) {

        BlockReference br = (BlockReference)mBlockReferenceList[i];
        BlockTableRecord blockRecord = (BlockTableRecord)tr.GetObject(br.BlockTableRecord, OpenMode.ForRead);



        foreach (ObjectId subId in blockRecord)
        {

             //get text, curve, splines and so on

        }

    }

 

}

 

The dwg file showing in the AUTOCAD is like the image of AutoCAD.PNG, what I did is now showing like MyFetch.PNG.

Apparently I get too much useless stuff. But I don't know how to filter them. And I think the problem is caused by the BlockReference or the entity is invisible or hidden, but i tried to compare all the properties they all seems like same no matter the entity should show or should not show.

Any ideas ?

Any help is appreciated!

Thanks a huge!

0 Likes
Accepted solutions (1)
1,051 Views
4 Replies
Replies (4)
Message 2 of 5

BKSpurgeon
Collaborator
Collaborator

Hi there

 

Would you be able to clarify your question because I didn't undersetand. best regards

 

0 Likes
Message 3 of 5

Anonymous
Not applicable

@BKSpurgeon

 

I tried to extract all the geoms in the model space, there are two attachments I uploaded, the autocad.png is how it looks in Autocad2018, the other one is the svg I exported, i found that i exported a lot of more stuff which is not showing in the autocad,

 

https://forums.autodesk.com/t5/net/how-to-get-the-blockreference-s-clip-range/td-p/7988972

Please check this question too, that I found it's because of the blockreference is been clipped, but I dont know how to get the clip range now.

 

0 Likes
Message 4 of 5

ActivistInvestor
Mentor
Mentor

Your code doesn't account for visibility of entity layers and viewport-layer overrides (layer frozen globally or layer frozen in viewport).

 

You have to check the layer of every entity to ensure that it is on and not frozen globally, and in the viewport.  

 

You also have to check to see if an object is within a viewport's field of view (clipped or not clipped), which is not a simple process.

 


@Anonymouswrote:

I am using realDwg to fetch 2d shape form a dwg file.

 

I found I get too much geom which is not showing in the autoCAD.

 

I found the problem is that the BlockTableRecord contains too many useless BlockReferences.

Each one has its own entity of Curves and shapes.

 

Here is my code: 

foreach (ObjectId id in ms)
{

    Entity ent = (Entity)tr.GetObject(id, OpenMode.ForRead);

    //if entity is text polyline, or other stuff, just save them and show them in svg later

 

    if(ent is BlockReference) {

        BlockReference br = (BlockReference)mBlockReferenceList[i];
        BlockTableRecord blockRecord = (BlockTableRecord)tr.GetObject(br.BlockTableRecord, OpenMode.ForRead);



        foreach (ObjectId subId in blockRecord)
        {

             //get text, curve, splines and so on

        }

    }

 

}

 

The dwg file showing in the AUTOCAD is like the image of AutoCAD.PNG, what I did is now showing like MyFetch.PNG.

Apparently I get too much useless stuff. But I don't know how to filter them. And I think the problem is caused by the BlockReference or the entity is invisible or hidden, but i tried to compare all the properties they all seems like same no matter the entity should show or should not show.

Any ideas ?

Any help is appreciated!

Thanks a huge!


 

0 Likes
Message 5 of 5

Anonymous
Not applicable
Accepted solution

@ActivistInvestor

 

Thx a lot, that's right to add visible and layer logic and so on, which I did later, and has some effects now.

 

The last problem is the clip stuff you mentioned, I do find this link : 

http://through-the-interface.typepad.com/through_the_interface/2012/10/querying-for-xclip-informatio...

 

very helpful to check the XClip stuff.

 

But the question now is, if you check the link carefully, you can see it is only used as a simple rectangle clipping.

 

My question is , if I do clip the mode with some range, like the rectangle range. THEN I ROTATE THE BLOCKREFERENCE AND MOVE THE BLOCK A LITTLE,  then I found the control points mentioned in this link is never changed. But the fil.GetQueryBounds still gives me a new bounds, since it's been rotated, this new bounds is not what I am looking for now. Which means I LOST the correct clipping range.

 

How to solve this? Did I discribe the question clearly?

0 Likes