I am trying to automatically add some hyperlinks to entities in my drawings but I am encountering an issue that I do not know how to readily solve. After adding the hyperlink, the drawing path is added to the beginning of the hyperlink which is what I do not want. Here is my code to get the hyperlink.
Private Sub AddHyperLinkToEntity(entity As Entity, pidData As PidXData) Dim linkCollection As HyperLinkCollection = entity.Hyperlinks linkCollection.Add(CreateHyperlink(pidData)) End Sub Private Function CreateHyperlink(data As PidXData) As HyperLink Dim hyperLink As HyperLink = new HyperLink() hyperLink.Description = "blahblahblah" hyperLink.Name = $"http//www.blahblahblah.com/pdf?programcode='{data.ProgramCode}'?idcount='{data.IdCount}'" hyperLink.SubLocation = string.Empty Return hyperLink End Function
It is pretty standard code with nothing special in it. However, when i print to pdf or look at the link in the properties, the link has been appended to the drawing location.
C:\Demo - Files\02b_PID\http//www.blahblahblah.com/pdf?programcode='301'?idcount='100738'
Is there a way in code to get the link to not add the current drawing path?
Solved! Go to Solution.
Solved by Keith.Brown. Go to Solution.
I'm pretty sure that the value of the HYPERLINKBASE system variable is prefixed to the name when the hyperlink is created.
@Keith.Brown wrote:I am trying to automatically add some hyperlinks to entities in my drawings but I am encountering an issue that I do not know how to readily solve. After adding the hyperlink, the drawing path is added to the beginning of the hyperlink which is what I do not want. Here is my code to get the hyperlink.
Private Sub AddHyperLinkToEntity(entity As Entity, pidData As PidXData) Dim linkCollection As HyperLinkCollection = entity.Hyperlinks linkCollection.Add(CreateHyperlink(pidData)) End Sub Private Function CreateHyperlink(data As PidXData) As HyperLink Dim hyperLink As HyperLink = new HyperLink() hyperLink.Description = "blahblahblah" hyperLink.Name = $"http//www.blahblahblah.com/pdf?programcode='{data.ProgramCode}'?idcount='{data.IdCount}'" hyperLink.SubLocation = string.Empty Return hyperLink End FunctionIt is pretty standard code with nothing special in it. However, when i print to pdf or look at the link in the properties, the link has been appended to the drawing location.
C:\Demo - Files\02b_PID\http//www.blahblahblah.com/pdf?programcode='301'?idcount='100738'Is there a way in code to get the link to not add the current drawing path?
That was my believe also but the value is nothing when i checked the parameter. I guess i can try setting the value to nothing again immediately before trying to set the hyperlink.
Ok, i found the issue. The problem was with my hyperlink. I was missing the colon after the http so autocad rightfully determined that this was not a valid url and decided that it was instead a bookmark in the current file. Dumb mistake that cost me a couple of hours.