Author Topic: REMOVING EXISTING HYPERLINKS  (Read 2829 times)

0 Members and 1 Guest are viewing this topic.

Matersammichman

  • Guest
REMOVING EXISTING HYPERLINKS
« on: June 30, 2006, 09:49:57 AM »
I'm using VB6 to open CAD drawings and want to remove existing Hyperlinks from the dwgs. I can make this work in VBA, but not pure VB.
Help? :lol:

DaveW

  • Guest
Re: REMOVING EXISTING HYPERLINKS
« Reply #1 on: June 30, 2006, 10:37:11 AM »
Do you have sucessful vb6 projects working?

Are you making an activex dll? If so, how are you linking to it?

Your info is lacking. :)

Post some code.

Also, if you need help setting up a pure vb project, take a look at this:
http://www.websitetoolbox.com/tool/post/milllister/vpost?id=1071084&trail=30#1

You can go back to the http://milllister.com/ page and grab my phone and call me if you need help debuging in design time.

Matersammichman

  • Guest
Re: REMOVING EXISTING HYPERLINKS
« Reply #2 on: June 30, 2006, 11:07:50 AM »
Here's what I tried...

Dim ACADHYPERLINK As Object
Set ACADHYPERLINK = acadDoc.ACADHYPERLINK
For Each ACADHYPERLINK In acadDoc
ACADHYPERLINK.Delete
Next ACADHYPERLINK

...needless to say, it didn't work.

Bob Wahr

  • Guest
Re: REMOVING EXISTING HYPERLINKS
« Reply #3 on: June 30, 2006, 11:32:52 AM »
nope it didn't.  give this a shot, will probably require some tweakage.
Code: [Select]
Sub test()
Dim objHL As AcadHyperlink
Dim objHLs As AcadHyperlinks
Dim objThingy As AcadEntity
For Each objThingy In acadDoc.PaperSpace
  If objThingy.Hyperlinks.Count <> 0 Then
    Set objHLs = objThingy.Hyperlinks
    For Each objHL In objHLs
      objHL.Delete
    Next objHL
  End If
Next objThingy
For Each objThingy In acadDoc.PaperSpace
  If objThingy.Hyperlinks.Count <> 0 Then
    Set objHLs = objThingy.Hyperlinks
    For Each objHL In objHLs
      objHL.Delete
    Next objHL
  End If
Next objThingy

End Sub
That was VBA done then thisdrawing was changed to acaddoc so you will have to set acaddoc, etc.

Bob Wahr

  • Guest
Re: REMOVING EXISTING HYPERLINKS
« Reply #4 on: June 30, 2006, 11:43:57 AM »
Here's what I tried...

Dim ACADHYPERLINK As Object
Set ACADHYPERLINK = acadDoc.ACADHYPERLINK
For Each ACADHYPERLINK In acadDoc
ACADHYPERLINK.Delete
Next ACADHYPERLINK

...needless to say, it didn't work.
Just for the understanding side of it, the reason that won't work is that what you are telling VB is that it's going to iterate through everything in the drawing AND that everything in the drawing that it will find is a hyperlink.  The first thing it gets to that isn't a hyperlink, the program says, "Hey, this isn't a hyperlink you.  I think I'm going to toss the binky." 

The only time that code would work is if you had a drawing that contained absolutely nothing but hyperlinks which won't ever ever happen for two reasons.

1) paperspace and modelspace are both blocks and you can't get rid of them.
2) you can't have a hyperlink in a drawing.  Hyperlinks are attached to objects, not objects in their own right.

Make sense?

Matersammichman

  • Guest
Re: REMOVING EXISTING HYPERLINKS
« Reply #5 on: June 30, 2006, 12:48:44 PM »
Bob,
I am on VB6 Learning Edition...

I tried your code, but VB6 isn't recognizing "Dim objHL As AcadHyperlink". It gives me an error, "user-defined type not defined". What else do I need to do?

Dave,
Constructive criticim is always welcome...Good code is always welcome too.
I'm a newb at using VB6 to access Cad.

Chuck Gabriel

  • Guest
Re: REMOVING EXISTING HYPERLINKS
« Reply #6 on: June 30, 2006, 01:03:41 PM »
Sounds like you need to add a reference to the AutoCAD type library.

Also, if you iterate over the database like below, it will get any links embedded in blocks in addition to the ones in modelspace and paperspace.

Code: [Select]
Sub removeHyperLinks(ByRef doc As AcadDocument)
  Dim block As AcadBlock
  For Each block In doc.Blocks
     Dim ent As AcadEntity
     For Each ent In block
      Dim links As AcadHyperlinks
      Set links = ent.hyperLinks
      If links.Count <> 0 Then
        Dim link As AcadHyperlink
        For Each link In links
          link.Delete
        Next link
        Set link = Nothing
      End If
     Next ent
     Set ent = Nothing
  Next block
  Set block = Nothing
End Sub

Glenn R

  • Water Moccasin
  • Posts: 1932
  • What idiot child of married cousins wrote this?!
Re: REMOVING EXISTING HYPERLINKS
« Reply #7 on: June 30, 2006, 09:49:33 PM »
Chuck wins!

Exactly how I would have done it Chuck - like minds and all the rest of it...;)

Cheers,
Glenn.
Me

Chuck Gabriel

  • Guest
Re: REMOVING EXISTING HYPERLINKS
« Reply #8 on: July 01, 2006, 03:35:44 PM »
Exactly how I would have done it Chuck - like minds and all the rest of it...;)

Twins separated at birth perhaps?  You don't, by chance, have one leg shorter than the other and a large back hump, do you?  :-D

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: REMOVING EXISTING HYPERLINKS
« Reply #9 on: July 01, 2006, 07:35:19 PM »
:lol:

If you enjoy bourbon Chuck, that clinches it for me.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--

Glenn R

  • Water Moccasin
  • Posts: 1932
  • What idiot child of married cousins wrote this?!
Re: REMOVING EXISTING HYPERLINKS
« Reply #10 on: July 01, 2006, 09:09:30 PM »
Probably triplets with that comment brother Kerry ;)
Me