Travailler avec les hyperliens
Mettre à jour un hyperlien dans un DWG
Aspose.CAD pour .NET vous permet d’accéder à l’hyperlien dans un dessin AutoCAD en utilisant le CadBaseEntity.Hyperlink. Vous pouvez accéder à chaque hyperlien de cette collection un par un et modifier ses propriétés.
Exemple de code
Le code d’exemple suivant accède à toutes les entités de l’image et change leur propriété Hyperlink en fonction du site web d’Aspose.
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
string dwgPathToFile = MyDir + "AutoCad_Sample.dwg"; | |
using (CadImage cadImage = (CadImage)Image.Load(dwgPathToFile)) | |
{ | |
foreach (CadBaseEntity entity in cadImage.Entities) | |
{ | |
if (entity is CadInsertObject) | |
{ | |
CadBlockEntity block = cadImage.BlockEntities[((CadInsertObject)entity).Name]; | |
if (!string.IsNullOrEmpty(block.XRefPathName.Value)) | |
{ | |
block.XRefPathName.Value = "new file reference.dwg"; | |
} | |
} | |
if (entity.Hyperlink == "https://products.aspose.com") | |
{ | |
entity.Hyperlink = "https://www.aspose.com"; | |
} | |
} | |
} | |