PDA

View Full Version : Automatic hyperlink through lisp?


Mr Cory
2007-03-22, 03:21 AM
Hay people!

This may be a little far out there or me being too lazy but is there any way to attach a hyperlink to a block (inserted from tool palette) which, when insert lookes to a specfic folder and looks for a excel file in that folder?

Im using the project navigator specfies the path to the project (the field expression for this path is %<\AecPr "ProjectLocation">%)

What i would like is if the hyperlink referenced to an excel file in the folder that the above points to.
If it helps the excel file can be called the same for every project "wall bracing.xls"

Cheers for any help!

Mr Cory
2007-03-22, 05:08 AM
Even if it was to attach a hyperlink to any object though the lisp. Not worrying about inserting off the tool palette eg

Command xlhyper
select object
lisp looks at project navigator
lisp finds path (project path)
lisp adds hyperlink to object

Ed Jobe
2007-03-22, 04:06 PM
I've posted code for creating hyperlinks in the vba forum. You could look over there and translate it to lisp.

Mr Cory
2007-03-22, 10:33 PM
Do you mean this one (http://forums.augi.com/showthread.php?t=7356&highlight=hyperlink)?

Ed Jobe
2007-03-22, 11:30 PM
Do you mean this one (http://forums.augi.com/showthread.php?t=7356&highlight=hyperlink)?
No, I thought I had posted the code. Here is a sample.

Dim oEnt As AcadEntity
Dim hyp As AcadHyperlink
Dim str As String
'Set oEnt using some selection method.
Set hyp = oEnt.Hyperlinks.Add(str)
hyp.URL = InputBox(str, "URL", hyp.URL)
hyp.URLDescription = InputBox(str, "URL Description", hyp.URLDescription)
Since oEnt.Hyperlinks is a collection, you can add as many urls as you want.

Mr Cory
2007-03-22, 11:33 PM
Is oEnt a VB function?

So what does that function do exactly?

Ed Jobe
2007-03-22, 11:37 PM
Is oEnt a VB function?

So what does that function do exactly?
See the first line to find out what oEnt is.

The sample takes an entity and prompts the user to enter a url and url description and adds it to the Hyperlinks collection. Every entity has a Hyperlinks collection.

Mr Cory
2007-03-22, 11:39 PM
Sweet so how can i get the url path from the Project navigator using lisp?

Ed Jobe
2007-03-22, 11:54 PM
I don't know if that's possible in lisp. The pn file is in xml. I've done it in vb.net. I don't know of any lisp tools that can read xml. You can open xml as a text file, but you better know xml really good.

Mr Cory
2007-03-22, 11:57 PM
Reading xml isnt a prob as i have xmlnotepad.

So your saying it would be easier to use VB instead of lisp?

Ed Jobe
2007-03-23, 12:13 AM
I don't mean "read" as in "with your eyes". I'm referring to programatically reading the contents of a file into memory, so you can obtain the info you want.

Without some lisp wrapper library for xml (such as doslib for dos), I would use vba at least (you can get xml lib's) or .Net, which has xml support built in.

Mr Cory
2007-03-23, 12:21 AM
Duh :Oops:

OK youv lost me lol I try marco as you found my other question ;)

Mr Cory
2007-03-23, 12:41 AM
What would the code be if it was Vb to get the path out of the .apj file?

I opened it with notepad and it said it was xml version one.
The info i need to get out of it is ProjectLocation="c:\blah....\" Then i need to add "wall bracing.xls" to the end of the path and have that entered into the prompt for the hyperlink path