DGN 도면

DWG의 일환으로 DGN 형식 그리기

Aspose.CAD for Java는 개발자가 내장된 DGN 언더레이가 포함된 DWG 파일을 내보낼 수 있도록 합니다. 다음은 DWG 파일을 내보내는 동안 DWG 파일 내의 DGN 언더레이에 접근하는 방법을 보여주는 코드입니다.

// Input and Output file paths
String dataDir = Utils.getDataDir(ExportDGNAsPartofDWG.class) + "ExportingDGN/";
// Input and Output file paths
String fileName = dataDir + "BlockRefDgn.dwg";
String outPath = dataDir +"BlockRefDgn.dwg.pdf";
// Create an instance of PdfOptions class as we are exporting the DWG file to PDF format
com.aspose.cad.imageoptions.PdfOptions exportOptions = new com.aspose.cad.imageoptions.PdfOptions();
// Load any existing DWG file as image and convert it to CadImage type
com.aspose.cad.fileformats.cad.CadImage cadImage = (com.aspose.cad.fileformats.cad.CadImage) com.aspose.cad.Image.load(fileName);
// Go through each entity inside the DWG file
for (com.aspose.cad.fileformats.cad.cadobjects.CadBaseEntity baseEntity : cadImage.getEntities())
{
// Check if entity is an image definition
if (baseEntity.getTypeName() == com.aspose.cad.fileformats.cad.cadconsts.CadEntityTypeName.DGNUNDERLAY)
{
com.aspose.cad.fileformats.cad.cadobjects.CadDgnUnderlay dgnFile = (com.aspose.cad.fileformats.cad.cadobjects.CadDgnUnderlay)baseEntity;
// Get external reference to object
System.out.println(dgnFile.getUnderlayPath());
}
}
// Define settings for CadRasterizationOptions object
com.aspose.cad.imageoptions.CadRasterizationOptions vectorRasterizationOptions = new com.aspose.cad.imageoptions.CadRasterizationOptions();
vectorRasterizationOptions.setPageWidth(1600);
vectorRasterizationOptions.setPageHeight(1600);
vectorRasterizationOptions.setLayouts(new String[] { "Model" });
vectorRasterizationOptions.setAutomaticLayoutsScaling(false);
vectorRasterizationOptions.setNoScaling(true);
vectorRasterizationOptions.setBackgroundColor(com.aspose.cad.Color.getBlack());
vectorRasterizationOptions.setDrawType(com.aspose.cad.fileformats.cad.CadDrawTypeMode.UseObjectColor);
// Set Vector Rasterization Options
exportOptions.setVectorRasterizationOptions(vectorRasterizationOptions);
// Export the DWG to PDF by calling Save method
cadImage.save(outPath, exportOptions);

DGN v7의 3D 엔터티 지원

Aspose.CAD for Java API는 DGN AutoCAD 파일을 로드하고 DGN v7에 대한 3D 엔터티를 지원하는 기능을 소개했습니다. CadImage 클래스는 이 목적을 수행합니다. 각 DGN 이미지는 9개의 미리 정의된 보기를 지원합니다. 이는 1에서 9까지 열거됩니다. 내보내는 동안 보기가 정의되지 않은 경우, 다중 페이지 출력 형식(예: PDF)의 경우 모든 보기가 내보내지며, 각 보기마다 별도의 페이지에 표시됩니다. DGN 파일 형식에서는 2D뿐만 아니라 3D 엔터티도 지원됩니다.

VectorRasterizationOptions.TypeOfEntities는 DGN 형식에서는 더 이상 사용되지 않으며(2D와 3D를 동시에 지원함), 이에 대한 샘플 코드는 지원되는 DGN 요소를 확인하는 데 도움이 됩니다.

String fileName = dataDir + "Nikon_D90_Camera.dgn";
String outFile = dataDir + "Nikon_D90_Camera.dgn";
DgnImage objImage = (DgnImage)com.aspose.cad.Image.load(fileName);
PdfOptions options = new PdfOptions();
CadRasterizationOptions vectorOptions = new CadRasterizationOptions();
vectorOptions.setPageWidth(1500);
vectorOptions.setPageHeight(1500);
vectorOptions.setAutomaticLayoutsScaling(true);
vectorOptions.setBackgroundColor(Color.getBlack());
vectorOptions.setLayouts(new String[] { "1", "2", "3", "9" });//only export 4 (1,2,3 and 9) views
options.setVectorRasterizationOptions(vectorOptions);
objImage.save(outFile, options);
// Input and Output file paths
String fileName = "BlockRefDgn.dwg";
String outPath = "BlockRefDgn.dwg.pdf";
DgnImage dgnImage = (DgnImage)Image.load(dataDir);
{
for (DgnDrawingElementBase element : dgnImage.getElements())
{
switch (element.getMetadata().getType())
{
case DgnElementType.Line:
case DgnElementType.Ellipse:
case DgnElementType.Curve:
case DgnElementType.BSplineCurveHeader:
case DgnElementType.Arc:
case DgnElementType.Shape:
case DgnElementType.PolyLine:
case DgnElementType.TextNode:
case DgnElementType.Text:
case DgnElementType.ComplexShapeHeader:
case DgnElementType.ComplexChainHeader:
{
//previously supported entities, now supported also for 3D
break;
}
case DgnElementType.SolidHeader3D:
case DgnElementType.Cone:
case DgnElementType.CellHeader:
{
//supported 3D entities
break;
}
}