how to use CopyToOtherImageTool
Posted: 05 Jun 2024, 04:43
i'm trying to evaluate this api for purchase as soon as i can prove it works. i'm having a lot of trouble understanding how to do anything other than what's in some examples on how to save files to different file types. i asked someone in sales and they told me i could use CopyToOtherImageTool and they also told me to make inserts out of the original files which helps paste them to a specific position. i havent found that code yet(creating inserts) but i did try the copy tool and this is my code. is this right? at the end the CADtoDwg.SaveAsDWG is failing and only tells me 'Object reference not set to an instance of an object.' but doesnt help me any more. from what i can tell i have a cadimage and a proper dwg file path selected as i am just opening a drawing and saving over it to the same name.
using CADImport;
using CADImport.Export;
using PRO = CADImport.Professional;
private void AddEntitiesToDrawing(string dxfDrawing, string drawingName, Point3D origin)
{
// copy entities and blocks from a dxf to the dwg
CADImage sourceCadImage = CADImage.CreateImageByExtension(dxfDrawing);
CADEntityCollection cadEntities = sourceCadImage.Converter.Entities;
CADEntityCollection cadBlocks = sourceCadImage.Converter.Blocks;
CADImage drawing = CADImage.CreateImageByExtension(_outputFile);
PRO.CopyToOtherImageTool copyTool = new PRO.CopyToOtherImageTool(drawing);
copyTool.CopyEntities(cadEntities);
copyTool.CopyEntities(cadBlocks);
copyTool.ActivateTool();
// add layout using drawingName later
// save the dwg
CADtoDWG.SaveAsDWG(drawing, _outputFile);
}
using CADImport;
using CADImport.Export;
using PRO = CADImport.Professional;
private void AddEntitiesToDrawing(string dxfDrawing, string drawingName, Point3D origin)
{
// copy entities and blocks from a dxf to the dwg
CADImage sourceCadImage = CADImage.CreateImageByExtension(dxfDrawing);
CADEntityCollection cadEntities = sourceCadImage.Converter.Entities;
CADEntityCollection cadBlocks = sourceCadImage.Converter.Blocks;
CADImage drawing = CADImage.CreateImageByExtension(_outputFile);
PRO.CopyToOtherImageTool copyTool = new PRO.CopyToOtherImageTool(drawing);
copyTool.CopyEntities(cadEntities);
copyTool.CopyEntities(cadBlocks);
copyTool.ActivateTool();
// add layout using drawingName later
// save the dwg
CADtoDWG.SaveAsDWG(drawing, _outputFile);
}