Author Topic: URI Hyperlink - Why does this not work?  (Read 1464 times)

0 Members and 1 Guest are viewing this topic.

Sheldon1874

  • Mosquito
  • Posts: 19
URI Hyperlink - Why does this not work?
« on: April 02, 2016, 11:21:39 AM »
Hi,

Trying to hyperlink to local drive jpg.  Why does below not work?
Code: [Select]
             
                Dim txtDB As New DBText()
                Dim strTxt As String = sFname
                txtDB.SetDatabaseDefaults()

                Dim hyperlinkColl As HyperLinkCollection = txtDB.Hyperlinks
                Dim hyperL As HyperLink = New HyperLink
                Dim uri As New System.Uri(fname)
                Dim convertUri = uri.AbsolutePath.ToString

                hyperL.Description = "Photograph"
                hyperL.Name = "Photograph"
                hyperL.SubLocation = convertUri
                hyperlinkColl.Add(hyperL)

                txtDB.Position = pt.Position
                txtDB.TextString = strTxt
                txtDB.Justify = AttachmentPoint.BaseLeft
                txtDB.AdjustAlignment(db)

                btr.AppendEntity(txtDB)
                tr.AddNewlyCreatedDBObject(txtDB, True)
                tr.Commit()

Thanks.

gile

  • Gator
  • Posts: 2520
  • Marseille, France
Re: URI Hyperlink - Why does this not work?
« Reply #1 on: April 02, 2016, 11:52:33 AM »
Hi,

Try to complete adding the DBText to the Database befor adding the hyperlink to the DBText.

Code - vb.net: [Select]
  1.                 Dim txtDB As New DBText()
  2.                 Dim strTxt As String = sFname
  3.                 txtDB.SetDatabaseDefaults()
  4.  
  5.                 txtDB.Position = pt.Position
  6.                 txtDB.TextString = strTxt
  7.                 txtDB.Justify = AttachmentPoint.BaseLeft
  8.                 txtDB.AdjustAlignment(db)
  9.  
  10.                 btr.AppendEntity(txtDB)
  11.                 tr.AddNewlyCreatedDBObject(txtDB, True)
  12.  
  13.                 Dim hyperlinkColl As HyperLinkCollection = txtDB.Hyperlinks
  14.                 Dim hyperL As HyperLink = New HyperLink
  15.                 Dim uri As New System.Uri(fname)
  16.                 Dim convertUri = uri.AbsolutePath.ToString
  17.  
  18.                 hyperL.Description = "Photograph"
  19.                 hyperL.Name = "Photograph"
  20.                 hyperL.SubLocation = convertUri
  21.                 hyperlinkColl.Add(hyperL)
  22.  
  23.                 tr.Commit()
Speaking English as a French Frog

Sheldon1874

  • Mosquito
  • Posts: 19
Re: URI Hyperlink - Why does this not work?
« Reply #2 on: April 02, 2016, 03:52:56 PM »
Aye, of course add the thingy to the dbase then muck about with it.  The next problem is then resolved here: http://adndevblog.typepad.com/autocad/2012/05/how-to-create-a-hyperlink-on-an-entity.html.  Use hyperl.name not hyperl.sublocation.

Thanks