Discuss and ask questions about CAD .NET library.
Moderators: SDS, support, admin
-
massimo
- Posts: 6
- Joined: 20 Oct 2009, 19:52
Post
by massimo » 20 Oct 2009, 20:00
I'm having trouble importing an "Insert" object from a "dwg" file.
I iterate all object in all layers of my dwg file but the iterator seems to skip the "Insert" object.
To read all objects i use this code:
Code: Select all
private CADImage image;
image.Converter.AutoInsert = true; // to get all the elements inside of inserts
image.Converter.Iterate(ReadCADEntities, null, cadParams);
and inside ReadCADEntities i check all EntityType.
What am i doing wrong?
Thank you.
Massimo
-
support
- Posts: 3272
- Joined: 30 Mar 2005, 11:36
-
Contact:
Post
by support » 23 Oct 2009, 12:50
Hello.
Your code is incorrect. DWG must be loaded to object of DWGImage class, which is a descendant of CADImage. For this purpose please use DWGImage.LoadFrom... method. The DWGImage.Converter.Iterate doesn't load entities, but converts DWG tree structure to a linear sequence of entities. Also setting the DWGImage.Converter.AutoInsert = true leads to delegate doesn't reference any methods for the CADInsert object.
Please see our demos' sources.
Alexander.
-
massimo
- Posts: 6
- Joined: 20 Oct 2009, 19:52
Post
by massimo » 27 Oct 2009, 17:24
Thanks, DWGImage worked.
But once i have the CADInsert entity, how am i supposed to transfer it to my pdf file i'm trying to generate?
It seems like the only information i have is the box that contains the entity.
Thanks
-
support
- Posts: 3272
- Joined: 30 Mar 2005, 11:36
-
Contact:
Post
by support » 28 Oct 2009, 12:20
Currently conversion to PDF doesn't supported. You can convert your image to DXF, EMF, WMF and raster formates. However, you can use ABViewer for conversion to PDF.
Alexander.
-
massimo
- Posts: 6
- Joined: 20 Oct 2009, 19:52
Post
by massimo » 28 Oct 2009, 13:04
Thanks for the answer.
Is there a way i can export the exact dwg file to a pdf file? Is there an "ExportPdf" method that I can use?
Thanks
Massimo
-
support
- Posts: 3272
- Joined: 30 Mar 2005, 11:36
-
Contact:
Post
by support » 28 Oct 2009, 13:43
No, there is no such method. You can't save as PDF, but to listed formats only. We plan to implement saving to PDF in the future versions.
Alexander.
-
massimo
- Posts: 6
- Joined: 20 Oct 2009, 19:52
Post
by massimo » 29 Oct 2009, 11:39
Hello,
i tried using this code:
Code: Select all
CADImage image = CADImage.CreateImageByExtension(dwgFile);
image.LoadFromFile(dwgFile);
using (StreamWriter io = new StreamWriter(pdfFile + "export.pdf", false))
{
CADToPDF toPdf = new CADToPDF(image);
toPdf.SaveToStream(io);
}
image.Dispose();
But this code gives me an error saying that index is out of range.
Could this work as a direct export to a pdf file?
Thanks.
Massimo
-
support
- Posts: 3272
- Joined: 30 Mar 2005, 11:36
-
Contact:
Post
by support » 29 Oct 2009, 17:13
Hello.
PDF is a vector graphics file format created by Adobe Systems. Did you know this format specification? Until you have library for correct conversion to PDF it's only wasting of time.
Alexander.
-
massimo
- Posts: 6
- Joined: 20 Oct 2009, 19:52
Post
by massimo » 30 Oct 2009, 12:42
Hello,
sorry, but i don't understand your last reply.
I tryied reading a dwg file and parsing all single entyties one by one using DWGImage but when it comes to CADInsert entyties it seems like i cannot do anything with it. But the rest of the pdf file i'm generating is correct and it's a vector graphic.
So i tryied using CADToPDF library (considering the name it looks like from a CAD file i can get a PDF file) but i get an error when i use the "SaveToStream" method.
Are you saying that i'm waisting my time using the CADToPDF library? So what is this library for?
Thank you
Massimo
-
support
- Posts: 3272
- Joined: 30 Mar 2005, 11:36
-
Contact:
Post
by support » 30 Oct 2009, 13:27
Hello Massimo.
Officially CAD Import .NET doesn't support export to PDF. This functional included into assembly, but it's unfinished and untested yet. And we can't guarantee correct saving to PDF.
Alexander.