การทำงานกับลิงก์
Contents
[
Hide
]ปรับปรุงลิงก์ใน DWG
Aspose.CAD สำหรับ Java ช่วยให้คุณเข้าถึงลิงก์ในภาพวาด AutoCAD โดยใช้ CadBaseEntity.getHyperlink(). คุณสามารถเข้าถึงลิงก์แต่ละรายการจากคอลเล็กชันนี้ทีละรายการและแก้ไขคุณสมบัติของมันได้
โค้ดตัวอย่าง
โค้ดตัวอย่างต่อไปนี้เข้าถึงเอนทิตีทั้งหมดของภาพและเปลี่ยนแปลงคุณสมบัติ Hyperlink ให้เป็นเว็บไซต์ Aspose
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String dataDir = Utils.getDataDir(EditHyperlink.class) + "DWGDrawings/"; | |
CadImage cadImage = (CadImage)Image.load(dataDir + "AutoCad_Sample.dwg"); | |
for (CadBaseEntity entity : cadImage.getEntities()) | |
{ | |
if (entity instanceof CadInsertObject) | |
{ | |
CadBlockEntity block = cadImage.getBlockEntities().get_Item(((CadInsertObject)entity).getName()); | |
String value = block.getXRefPathName().getValue(); | |
if (value != null && !value.contentEquals("")) | |
{ | |
block.getXRefPathName().setValue("new file reference.dwg"); | |
} | |
} | |
if (entity.getHyperlink() == "https://products.aspose.com") | |
{ | |
entity.setHyperlink("https://www.aspose.com"); | |
} | |
} | |