Trabajando con hiperenlaces
Contents
[
Hide
]Actualizar hiperenlace en un DWG
Aspose.CAD para Java te permite acceder al hiperenlace en un dibujo de AutoCAD utilizando el CadBaseEntity.getHyperlink(). Puedes acceder a cada hiperenlace de esta colección uno por uno y editar sus propiedades.
Código de muestra
El siguiente código de muestra accede a todas las entidades de la imagen y cambia su propiedad Hiperenlace a la página web de Aspose.
This file contains 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"); | |
} | |
} | |