ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Entity created by RealDWG will not appear properly

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
alanchen123
804 Views, 8 Replies

Entity created by RealDWG will not appear properly

Hi,

 

I use RealDWG to create a new DWG file(2014 format) and then add a circle entity to *Model_Space. Then open the DWG file in AutoCAD TrueView:

 

  1. In the “Model” panel, it is empty,
  2. Then I switch to “Layout1”, I can see the circle
  3. Then switch to “Layout2”, I can also see the circle.
  4.  Then when I switch back to “Layout1”, then it will become empty.
  5. Then switch back to “Layout2”, it is also empty now.

 

So I think there are some problems with the added entity but cannot figure out the reason. Please help! Thanks.

 

The DWG file is attached.

8 REPLIES 8
Message 2 of 9
owenwengerd
in reply to: alanchen123

Do your results change if you first ZOOM Extents so the circle is visible in model space?

--
Owen Wengerd
ManuSoft
Message 3 of 9
artc2
in reply to: alanchen123

Did you do a zoom extents in TrueView?  When I open the dwg file there is nothing visible, but when I do a zoom extents the circle is displayed.  Before the zoom extents the display region in my Acad is in the 490, 490 x 517, 505 region, but the circle is centered at 5.48,4.58 with a radius of 1.22 so it isn't in the intial view.

Message 4 of 9
alanchen123
in reply to: artc2

Great! I just change the Zoom extent in TrueView to "All", and the circle appears in "Model_Space", but not in "Layout1" and "Layout2". And in RealDWG, how to set the ZOOM extents programmingly so that the intial opened Model_space will display the circle in the correct position and full extents?

 

Thank you very much

Message 5 of 9
artc2
in reply to: alanchen123

When I use Acad to open the dwg you attached and then I switch to layout1 and layout2 I see the circle in the Model Space viewport in each of the layouts.

 

Take a look at the creatent sample app in the RealDWG SDK.  In _tmain() function at the end of creatent.cpp it creates a new drawing, adds a line to model space and then sets the extents and the viewport so that the line will show up when the drawing is opened in Acad.

Message 6 of 9
alanchen123
in reply to: artc2

Thank you. I just check the sample code. Just wonder:

 

1. Which code snippet is necessary for the objects to displayed? The code to set the extents, or the code to set the active viewport? Or both?

 

2. And for a drawing, must I set the active viewport manually? Will there be a default active view port if I do not set with codes manuallY?

 

3. I see in the sample, both the codes to set the extents and the active viewport is using hardcode numbers, which means for another entity, I may need to recalculate the values and re-hardcode the values into the codes. Is there a way to NOT hardcode the numeric values and also make sure all the visible entities in a drawing will be displayed in the full extents of the view when opened by TrueView or AutoCAD? Need I use a algorithm to enumerate all the entities in the drawing, obtain their boundaries, and then canculate the boundaries for all of them, so to set the viewport accordingly? It seems a little complex so if there is a ready-to-use function to do so, that will be better.

 

Thank you very much!

 


@artc2 wrote:

When I use Acad to open the dwg you attached and then I switch to layout1 and layout2 I see the circle in the Model Space viewport in each of the layouts.

 

Take a look at the creatent sample app in the RealDWG SDK.  In _tmain() function at the end of creatent.cpp it creates a new drawing, adds a line to model space and then sets the extents and the viewport so that the line will show up when the drawing is opened in Acad.


 

Message 7 of 9
artc2
in reply to: alanchen123

I would set both the extents and the viewport, but I don't think that the extents are required to get the entity to display when the dwg is opened in acad or trueview.

 

Yes there's a default viewport, but it doesn't default to the correct view parameters for your entity to show.  That's why you need to explicitly set the viewport parameters.

 

I'm not aware of any ready-to-use function to get the extents.  You'll have to iterate through the model space BlockTableRecord and call getGeomExtents() on each entity to get the full extents of that BlockTableRecord.

Message 8 of 9
owenwengerd
in reply to: alanchen123

Take a look at AcDbDatabase::updateExt() to see if that works to update the database extents. If so, you can update, then use the calculated extents stored in the database.

--
Owen Wengerd
ManuSoft
Message 9 of 9
artc2
in reply to: owenwengerd

Oops, forgot about that one.  It will iterate the Model Space BlockTableRecord calling getGeomExtents() on all entities except BlockReferences on which it will call geomExtentsBestFit() instead.  And, of course, it updates the extents to the min and max found.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost