Hook CAD software to PDFs

First, I’m new to Hook and new to applescript/scripting.

I use a CAD program called Vectorworks for my job. I’m constantly opening PDF’s to review plans and plot.

My ultimate goal is to open my vectorworks file and see its related PDFs that are linked to it.

Trying to Create an Integration Script for Vectorworks

Getting an address for a Vectorworks Document

My thoughts were to get the filepath of the document to use as the Hook address.

I’m not sure if using the file path is acceptable or even ideal.


Getting the Filepath for Vectorworks Document

Vectorworks has a SDK for plugin developement and its own scripting language, Vectorscript, but I can also use Python. Vectorworks Developer

My attempt at creating an integration script has not been great…

In Vectorworks, using Python I’m able to get the filepath of the current document.

I’m not a programmer, so I’m sure this is terrible, however it worked.

import subprocess

def Path():
    
    filePath = vs.GetFPathName()
    filePath = filePath[1:]
    subprocess.run("pbcopy", universal_newlines=True, input=filePath)
    vs.AlrtDialog(filePath)

Path()

So now that the filepath is copied to my clipboard, I use applescript to create the hook link

-- Append clipboard to Hook Link
set cp to POSIX path of clipboard

-- Get Address
set hookPath to "file://" & (the clipboard)

Creating the Name

Using applescript, I’m able to get the name of the currently selected tab in Vectorworks


tell application "Vectorworks 2021"
	set current_name to name of item 1 in windows
end tell

The Problems…

  1. In order to hook anything, I have to run my python script in Vectorworks. Is there a better was to create my address to the file…
    Here is a video showing my problem. I’m in the file, which I have already hooked to a few PDFs. Here are the steps I’m doing in the video.

    1. I invoke Hook and it finds no linkable file…
    2. I run my python script that puts the filePath to clipboard.
    3. I invoke Hook again, and it finds my hooked PDFs.
      Vectorworks Hook
  2. Is using the filePath as an address bad? Is using the name of the document for Get Name bad? I hardly ever move or rename files, however, I’m assuming this will break my previous links if I did this. I haven’t had the time to really play and test.

Any help or suggestions is greatly appreciated.

Thank you.