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:
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.
Solved! Go to Solution.
Solved by owenwengerd. Go to Solution.
Do your results change if you first ZOOM Extents so the circle is visible in model space?
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.
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
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.
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.
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.
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.
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.