Hi!
I am trying to create a script to add links to PDFs. For an example 2000 borehole elements that I want to add a link to.
I have recorded doing it manually and then cleaned up the code. My problem is it stops during the scipt...
Sub LinkToElement()
'Script scans elements
'For each element find a value in a excelfile PDF path etc
'Fix/sort the found values so that I can add it in the "CadInputQueue.SendKeyin Links Add Element ID ""Test.dgn"" 12345" below. Do not show that in the example below. Keep it simple :)
Part 1
Dim modalHandler As New Macro1ModalHandler AddModalDialogEventsHandler modalHandler
CadInputQueue.SendKeyin "Links Add Element ID ""Test.dgn"" 12345"
RemoveModalDialogEventsHandler modalHandler
CommandState.StartDefaultCommand
End Sub
The CadInputqueue tells what element that should have the link.
Part 2
Implements IModalDialogEventsPrivate Sub IModalDialogEvents_OnDialogClosed(ByVal DialogBoxName As String, ByVal DialogResult As MsdDialogBoxResult)
Private Sub IModalDialogEvents_OnDialogOpened(ByVal DialogBoxName As String, DialogResult As MsdDialogBoxResult)
If DialogBoxName = "Create Links" Then
DialogResult = msdDialogBoxResultCancel
End If ' Create Links
My Macro1ModalHandler never continues when the "Create Links" toolbox open. Even if I only add DialogResult = msdDialogBoxResultCancel as a test in the Macro1ModalHandler it doesen't work. So it seems like the "Creat Links" box is in some kind of a modalmode and it stops the script from continuing.
Part 1 works if i choose the PDF manually. Then it adds the link on the element perfectly. It is my Macro1ModalHandler that I have trouble with...
Is there a work around?
Is there a keyin that directly add a link? Something like: Links Add Element ID ""Test.dgn"" 12345 C:\Users\*****\Desktop\PDF\T636.PDF
I only want to create link to a file. Not KeyIn or URL.
Thanks!
HI Björn,
if you will search for this topic, you will receive quite a lot of results, which demonstrates this topic is not very simple, because key-ins are not published.
In my opinon the simplest solution is to add elements to selection set (you can use any proper method) and to use key-in
ELEMENT CREATE LINK FILE <file>
It will attach specified file to all selected elements.
You should be aware of:
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Thanks Jan!
Works great!
It was the FILE part I missed out.
Regards Björn