How to create hyperlink and attach to an element in VBA?
Regards,
Jeffrey Kam
If by Hyperlink you mean an Engineering Link then it's done using tags. MicroStation uses a tag set named 'Internet' that contains tag definitions 'URL' and 'description' plus some others. MicroStation's Engineering Links tool will interpret tags created with that tag set and follow the hyperlink contained in the URL tag.
With VBA, you create tags in the usual way using the 'Internet' tag set definition.
Regards, Jon Summers LA Solutions
I did with the code followings
TagSet tagset = app.ActiveDesignFile.TagSets.Add("Internet");
TagDefinition tag = tagset.TagDefinitions.Add("URL", MsdTagType.msdTagTypeCharacter);
tag.DefaultValue = "www.google.com";
tag = tagset.TagDefinitions.Add("description", MsdTagType.msdTagTypeCharacter);
elm.Current.AddTag(tag);
elm.Rewrite();
but it seems not work, what's wrong with my code?
Jeffrey
You're confusing the Tag Set Definition with the TagElement you want to attach to a host element.
See our Tag Data overview.
The Internet tag set defines a tag set that has at least two Tag Definition children: URL and Description.
You need to check whether the active DGN file already has the Internet tag set before you attempt to create it.
You can create & attach TagElements only if the Tag Set is already defined. You need a TagDefinition to be able to create a TagElement — the tag definition must already exist in the DGN file.
Suppose Internet tagset with URL and Description TagDefinition defined in the design file, please take a look of my codes belows
TagSet tagset = app.ActiveDesignFile.TagSets["Internet"];
TagDefinition tag = tagset.TagDefinitions["URL"];
TagElement tagElm = elm.AddTag(tag);
tagElm.Value = "http://www.google.com";
tagElm.Rewrite();
tag = tagset.TagDefinitions["Description"];
TagElement tagElm2 = oEE.Current.AddTag(tag);
tagElm2.Value = "google";
tagElm2.Rewrite();
The engineering link still not works. Can you see my problems?
this code works. sorry for misleading you. Thank you