你好,我有个问题想咨询,怎样获取图纸的里多边形端点的顺序,例如CadLwPolyline或者CadPolyline里的端点。
@komorebi,
CadLwPolyline 有获取坐标和凸出数组的方法:
List<Cad2DPoint> coordinates = lwpolyline.getCoordinates();
List<Double> bulges = lwpolyline.getBugle();
有了它们,您就可以像显示的那样恢复有关 arc 的信息,例如,此处:Bulge Conversion Functions | Lee Mac Programming
Caused by: class com.aspose.cad.internal.Exceptions.InvalidOperationException: Cannot find resource ‘InitXRecordObjects_cadXRecord2.dat’.
com.aspose.cad.internal.qA.a.b(Unknown Source)
com.aspose.cad.fileformats.cad.DwgImage.(Unknown Source)
这个异常怎么解决?
@oleksii.gorokhovatskyi 你好我的代码如下:
public class CreateDWGDrawing2 {
public static void main(String[] args) {
MeteredLicensing.license();
String dataDir = Utils.getDataDir(CreateDWGDrawing2.class) + "DWGDrawings\\";
// String inputFilePath = dataDir + "SimpleEntites_1.dwg";
String outputFilePath = dataDir + "CreateDWGDrawing.dwg";
try {
DwgImage dwgImage = new DwgImage();
// 设置 DWG 图纸的属性
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
rasterizationOptions.setPageWidth(1600); // 设置页面宽度
rasterizationOptions.setPageHeight(1600); // 设置页面高度
rasterizationOptions.setAutomaticLayoutsScaling(true);
rasterizationOptions.setLayouts(new String[]{"Model"});
rasterizationOptions.setDrawType(CadDrawTypeMode.UseDrawColor);
rasterizationOptions.setVisibilityMode(VisibilityMode.AsScreen);
DwgOptions dwgOptionsBase=new DwgOptions() {
@Override
public FileFormat getTargetFormat() {
return FileFormat.CadR2000;
}
};
dwgOptionsBase.setVectorRasterizationOptions(rasterizationOptions);
// 将图纸保存到文件
dwgImage.save(outputFilePath,dwgOptionsBase);
dwgImage.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
报下面的错误:
Exception in thread “main” java.lang.ExceptionInInitializerError
at com.aspose.cad.examples.DWGDrawings.demo.CreateDWGDrawing2.main(CreateDWGDrawing2.java:22)
Caused by: class com.aspose.cad.internal.Exceptions.InvalidOperationException: Cannot find resource ‘InitXRecordObjects_cadXRecord2.dat’.
com.aspose.cad.internal.qA.a.b(Unknown Source)
com.aspose.cad.fileformats.cad.DwgImage.(Unknown Source)
com.aspose.cad.examples.DWGDrawings.demo.CreateDWGDrawing2.main(CreateDWGDrawing2.java:22)
at com.aspose.cad.internal.qA.a.b(Unknown Source)
at com.aspose.cad.fileformats.cad.DwgImage.(Unknown Source)
… 1 more
aspose-cad 的版本:
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-cad</artifactId>
<version>24.6.1</version>
<classifier>javadoc</classifier>
</dependency>
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-cad</artifactId>
<version>24.6.1</version>
</dependency>
@codejoy,
请注意,为了创建新的 DWG 文件,只需执行以下操作即可:
DwgImage dwgImage = new DwgImage();
dwgImage.save(outputFilePath);
但遗憾的是,我可以确认您针对此案例提供的例外情况。我们已创建 CADJAVA-11760 来解决此问题。