Bind all XREFs as a single file

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

thomascheah
Posts: 26
Joined: 17 Oct 2007, 06:46
Location: Malaysia
Contact:

Bind all XREFs as a single file

Post by thomascheah » 07 Jan 2008, 19:12

Hi,

How do I use CAD Import.NET load a DXF or DWG that contains XREFs, and then save them as a single DXF file with all XREFs binded?

Thanks in advance.

Regards,
Thomas

<b>Objective World Pvt. Ltd.</b>
"<i>Turning Knowledge Into Wisdom.</i>"
http://www.objectiveworld.com

thomascheah
Posts: 26
Joined: 17 Oct 2007, 06:46
Location: Malaysia
Contact:

Post by thomascheah » 10 Jan 2008, 09:02

Knock, knock. Anybody home? Or everyone is still on holiday? :)

<b>Objective World Pvt. Ltd.</b>
"<i>Turning Knowledge Into Wisdom.</i>"
http://www.objectiveworld.com

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Post by support » 10 Jan 2008, 09:35

Hello!

<b>CAD Import .NET</b> package (available at: http://www.cadsofttools.com/download/cadimportnet.zip) contains Viewer demo. Just run it, open necessary file which contains Xrefs and select <b>File > Save As DXF...</b> menu item.

Sergey.

Please post questions to the forum or write to support@cadsofttools.com

thomascheah
Posts: 26
Joined: 17 Oct 2007, 06:46
Location: Malaysia
Contact:

Post by thomascheah » 11 Jan 2008, 04:09

Yeah, I tried that. I notice the saved DXF file does not include the XREFs of the original file. That is, if I open the saved DXF file without the original XREF files, the drawing is somewhat incomplete. Is this the correct behavior? My expectation is that the saved DXF file should include the contents of the original XREF files.

Thanks!

Thomas

<b>Objective World Pvt. Ltd.</b>
"<i>Turning Knowledge Into Wisdom.</i>"
http://www.objectiveworld.com

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Post by support » 11 Jan 2008, 11:02

Saved DXF file contains just a path to an external file. AutoCAD does this way, so CAD Import .NET does the same.

Sergey.

Please post questions to the forum or write to support@cadsofttools.com

thomascheah
Posts: 26
Joined: 17 Oct 2007, 06:46
Location: Malaysia
Contact:

Post by thomascheah » 12 Jan 2008, 13:34

Hmmm.... So does it means there is no way for me to bind those XREFs into a single? How about programatically add all entities in the XREFs? Do you think it is possible?

<b>Objective World Pvt. Ltd.</b>
"<i>Turning Knowledge Into Wisdom.</i>"
http://www.objectiveworld.com

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Post by support » 14 Jan 2008, 14:40

This is possible, but all entities must be added "manually". It is necessary to go through the whole list of entities in the second CADImage object and to add them in to the first CADImage object. We recommend to use AssignEntity method (CADEntity.AssignEntity).

Sergey.

Please post questions to the forum or write to support@cadsofttools.com

thomascheah
Posts: 26
Joined: 17 Oct 2007, 06:46
Location: Malaysia
Contact:

Post by thomascheah » 15 Jan 2008, 10:51

Thanks! Can you provide me a brief tutorial or short code snippets or pseudocode to illustrate your idea? Assuming that I had load the DXF file (which CAD Import.NET will automatically resolves and loads all XREFs within it),

1. Do you mean I create an empty CADImage as destination, and then iterate through all entities including those that is within the XREFs in the source CAD image, and manually add it to the destination CADImage?

2. This looks kinda heavy. Can I do it by using a single CADImage? How do I iterate through the entities that are within those XREFs.

3. What does AssignEntity do? I can find AddEntity in the library, but I can't find AssignEntity. Is this something new that is just added to the upcoming release? So when is it going to be released? (You promised to notify me when it is out and I am waiting for a while.) :)

<b>Objective World Pvt. Ltd.</b>
"<i>Turning Knowledge Into Wisdom.</i>"
http://www.objectiveworld.com

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Post by support » 16 Jan 2008, 09:12

Hi Thomas,
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">1. Do you mean I create an empty CADImage as destination, and then iterate through all entities including those that is within the XREFs in the source CAD image, and manually add it to the destination CADImage?

2. This looks kinda heavy. Can I do it by using a single CADImage? How do I iterate through the entities that are within those XREFs.<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
Here goes a code example:

Code: Select all

<font color="blue">private void</font id="blue"> btnAssignEntity_Click(<font color="blue">object</font id="blue"> sender, System.EventArgs e)
{
	<font color="blue">if</font id="blue">(<font color="blue">this</font id="blue">.cadImage == <font color="blue">null</font id="blue">)
	{				
		<font color="blue">this</font id="blue">.cadImage = <font color="blue">new</font id="blue"> CADImage();		
		<font color="blue">this</font id="blue">.cadImage.UseDoubleBuffering = <font color="blue">false</font id="blue">;
		<font color="blue">this</font id="blue">.cadImage.InitialNewImage();
		SetLayList();					
	}
	<font color="blue">this</font id="blue">.cadImage.LoadFromFile(@"c:\Destination.dxf");
	CADImage cadImageSource = <font color="blue">new</font id="blue"> CADImage();
	cadImageSource.LoadFromFile(@"c:\Source.dxf");
	<font color="blue">for</font id="blue"> (<font color="blue">int</font id="blue"> i=0;i<cadImageSource.CurrentLayout.Converter.GetCounts(CADImport.FaceModule.ConvSection.Entities);i++)
	{				
		CADEntity entSource = cadImageSource.CurrentLayout.Converter.GetSection(CADImport.FaceModule.ConvSection.Entities).Entities[i];
		Type tp = entSource.GetType();
		CADEntity entity = (CADEntity)Activator.CreateInstance(tp);
		entity.AssignEntity(entSource);
		entity.Loaded(this.cadImage.Converter);
		<font color="blue">this</font id="blue">.cadImage.Converter.OnCreate(entity);	
		<font color="blue">this</font id="blue">.cadImage.CurrentLayout.Entities.Add(entity);
	}
	<font color="blue">this</font id="blue">.cadPictBox.Invalidate();
}
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">3. What does AssignEntity do? I can find AddEntity in the library, but I can't find AssignEntity. Is this something new that is just added to the upcoming release? So when is it going to be released? (You promised to notify me when it is out and I am waiting for a while.) :)<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
<b>CADEntity.AssignEntity Method</b> - copies an entity.
It is extended version of <b>CAD Import .NET</b> is required for getting access to AssignEntity Method. Please contact us to info@cadsofttools.com accordingly this question.

Sergey.

Please post questions to the forum or write to support@cadsofttools.com

thomascheah
Posts: 26
Joined: 17 Oct 2007, 06:46
Location: Malaysia
Contact:

Post by thomascheah » 18 Jan 2008, 04:55

Thanks for the short code and tutorial. We just got the latest release of CAD Import.NET Extended. (Dated on 24 December 2007.)

My biggest surprise (and possibly frustration) is, it seem that this release does not load XREFs correctly (or does not load them at all). When I tried to load the same DXF file (that contains XREFs) using the previous release of CAD Import.NET Extended library, it turns out correctly. Any reason why the latest version does not load the XREFs in DXF/DWG files? Or is there any switches or parameters to indicate whether to load XREFs explicitly?

Please advise. Thanks!

<b>Objective World Pvt. Ltd.</b>
"<i>Turning Knowledge Into Wisdom.</i>"
http://www.objectiveworld.com

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Post by support » 18 Jan 2008, 09:12

This problem must be solved. Can you please send us your XRef files to support@cadsofttools.com?

Sergey.

Please post questions to the forum or write to support@cadsofttools.com

thomascheah
Posts: 26
Joined: 17 Oct 2007, 06:46
Location: Malaysia
Contact:

Post by thomascheah » 18 Jan 2008, 16:26

Just sent you a DWG file with XREFs. Please check your email. Hopefully you can get it solved ASAP. Thanks!

Thomas

<b>Objective World Pvt. Ltd.</b>
"<i>Turning Knowledge Into Wisdom.</i>"
http://www.objectiveworld.com

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Post by support » 18 Jan 2008, 17:24

Hello Thomas,

We've got your files. Thank you. We will consider the problem and inform you when a solution is ready.

Sergey.

Please post questions to the forum or write to support@cadsofttools.com

thomascheah
Posts: 26
Joined: 17 Oct 2007, 06:46
Location: Malaysia
Contact:

Post by thomascheah » 23 Jan 2008, 16:28

Just managed to tried your code above on copying entities, hoping by doing so, I can copy all the entities in the source file, include those from the XREFs to a destination file. Here are some comments,

1. What is the Destination.dxf in your code above supposed to be?

2. I tried to replace your code on loading a Destination.dxf with instantiating a new CADImage, i.e. this.cadImage = new CADImage()

3. The saved DXF files seems a bit incomplete. A lot of entities that are missing, not to mention that those in the XREFs are not saved as well.

4. Is there any methods or properties in CADImage where I can enumerate for those entities that are loaded from XREFs? Or all of them are loaded and added to the CADImage.Converter.Entities collection?

Can you please advise me on how do I fix your code above to achieve my intention above? Thanks!

<b>Objective World Pvt. Ltd.</b>
"<i>Turning Knowledge Into Wisdom.</i>"
http://www.objectiveworld.com

thomascheah
Posts: 26
Joined: 17 Oct 2007, 06:46
Location: Malaysia
Contact:

Post by thomascheah » 23 Jan 2008, 16:35

5. Why does CADImage.Converter.XRefs.Count always return 0 even when I load a DWG file that I am 100% it contains XREFs. (Those that I emailed you.)

<b>Objective World Pvt. Ltd.</b>
"<i>Turning Knowledge Into Wisdom.</i>"
http://www.objectiveworld.com

Post Reply