Re: [Dxfreader-info] entity reading process
Status: Beta
Brought to you by:
allandaly
|
From: Allan D. <al...@br...> - 2009-02-28 16:50:29
|
Your code looks right for reading in the DXF file.
1. create the model BBDXFModel* model = [[BBDXFModel alloc] init];
2. load the dxf file [model loadDXFString:dxfFileContents];
3. analyze the dxf file structure [model getDXFFileStructure];
4. process the entities [model processEntities];
Eventually steps 2 - 4 should probably get combined into one step for
convenience, but for now keeping them separate might be helpful for
development and debugging.
To add a line so far I have been using a different DK method that you
are. Here's what I've been doing and it seems to work. This is the
method I call in my importer object. x1, y1, x2, an y2 are the 2D
coordinates for the start and end of the line.
- (void) addLineX1: (double) x1value
Y1: (double) y1value
X2: (double) x2value
Y2: (double) y2value;
{
// create a NSBezierPath for the line
NSBezierPath* aPath = [NSBezierPath bezierPath];
[aPath moveToPoint:NSMakePoint(x1value, y1value)];
[aPath lineToPoint:NSMakePoint(x2value, y2value)];
// create a DK drawable object, in this case a line (path)
DKDrawablePath *newLine = [[DKDrawablePath alloc]
initWithBezierPath:aPath];
// add the drawable object to the new layer
if ([lyr respondsToSelector:@selector(objects)])
{
[(DKObjectOwnerLayer *)lyr addObject:newLine];
}
}
I have not used the DKDrawablePath initWithStartingCoordinate:
endingCoordinate: grid: approach as you are doing, so I cannot speak
to that question. It seems like it should work.
One thing to remember is that the DK world is either "filpped" or "not
flipped." A "not flipped" world is where the 0,0 origin is in the
lower left corner, and a "flipped" world is where the origin in the
upper left corner. For some reason Graham has developed everything in
DK to be normal "flipped", which is the opposite of how most of us
think of the world, or at least how AutoCAD and other standard CAD
tools that I'm used to think of the world. Maybe the weird directions
you're getting are the result of you sending in objects in a "not-
flipped" coordinate system, but then having them be drawn in a
"flipped" coordinate system.
Please let me know what you figure out on this one.
-Allan
On Feb 28, 2009, at 7:45 AM, Michael Caron wrote:
> Hi list!
>
> Just wanted to make sure that I'm going about loading entities
> correctly. Seems that when I draw them into a DKDrawingLayer, I get
> incorrect directions and line widths (not sure if line widths are
> part of the DXF line entity though).
>
> Process for reading in the DXF File:
> BBDXFModel* model = [[BBDXFModel alloc] init];
> [model loadDXFString:dxfFileContents];
> [model getDXFFileStructure];
> [model processEntities];
>
> Process for translating LINE entities into DK lines:
>
> BBDXFEntityLine* line = (BBDXFEntityLine*) entity;
>
> // Ignoring z coordinates for the moment
> NSPoint sp;
> sp.x = [[line startPoint] x];
> sp.y = [[line startPoint] y];
> NSPoint ep;
> ep.x = [[line endPoint] x];
> ep.y = [[line endPoint] y];
>
> DKDrawablePath* dkline =
> [[DKDrawablePath alloc] initWithStartingCoordinate:sp
> endingCoordinate:ep
> grid:
> [self gridLayer]];
> return [dkline autorelease];
>
> Like I said, it seems that when I render this way, I'm getting weird
> directions, though the lines seem to be spatially correct, that is,
> they are in the right places relative to each other, just sort of
> rotated or something differently. It might be due to an error in
> scaling it to microns, however. I haven't looked too far into it.
>
> I also didn't see anything yet for getting the array of Header
> objects. Am I missing something? I will add it if it's not there. It
> was late... maybe I just totally overlooked it. Important to get
> measurement data from the Header for SonoDraw.
>
> Cheers.
>
> Michael
> ------------------------------------------------
> mic...@gm...
> http://techrad.wordpress.com
> http://mrcaron.wordpress.com
>
> ------------------------------------------------------------------------------
> Open Source Business Conference (OSBC), March 24-25, 2009, San
> Francisco, CA
> -OSBC tackles the biggest issue in open source: Open Sourcing the
> Enterprise
> -Strategies to boost innovation and cut costs with open source
> participation
> -Receive a $600 discount off the registration fee with the source
> code: SFAD
> http://p.sf.net/sfu/XcvMzF8H_______________________________________________
> Dxfreader-info mailing list
> Dxf...@li...
> https://lists.sourceforge.net/lists/listinfo/dxfreader-info
|