Bulk Create Link Types

I recently discovered that a quick way to bulk create attributes is by:

  1. Listing them like so Attribute1; Attribute2; Attribute3; in a document.
  2. Pasting the list of semicolon separated attributes into the Key attributes dialog box on a Note.

I was wondering whether something similar existed for creating link types? Where I can bulk create link types instead of making them one by one in the Link pane?
Thanks.

Nope; there isn’t.

However, it is possible with AppleScript:

Adding new links with per-link-type properties are done like so:

tell application "Tinderbox 9"
	tell front document
		make new linkType with properties {name:"tester1", color:"green", dotted:true, action:"$Color(destination)=\"bright blue\";"}
		make new linkType with properties {name:"tester2", color:"blue", arrow:1, bold:true, action:"$Color(destination)=\"bright red\";"}
		make new linkType with properties {name:"tester3", bold:true}
		make new linkType with properties {name:"tester4", color:"red", arrow:1, dashed:true, action:"$Color(destination)=\"bright red\";"}
		make new linkType with properties {name:"tester5"}
		make new linkType with properties {name:"tester6", color:"green", arrow:1, bold:true, dotted:true, dashed:true, action:"$Color(destination)=\"bright red\";"}
	end tell
end tell

Note the need to escape double-quotes used in a link action. If you’ve long/complex action code for a link type I’d suggest adding that via the Inspector after the link type is created: less scope for some odd quote-related confusion.

If you just wantyto create a number of default-spec link types, try this:

set linkTypeList to {"try1", "try2", "try3", "try4", "try5", "try6"}

tell application "Tinderbox 9"
	tell front document
		repeat with theItem in linkTypeList
			make new linkType with properties {name:theItem}
		end repeat
	end tell
end tell

Note, I’m not sure the ‘broad’ property works correctly in v9.5.2 (I’ve already reported this to support).

HTH :slight_smile:

3 Likes

Thanks for this. I’ll give it a shot.

1 Like

Huzzah! It works! And I just wrote my first ever Applescript from scratch. Thanks @mwra :grin:

1 Like

Note to future readers: that the linkTo() and linkFrom() operators implicitly create link types. If the action creates a link with a link type note already in use in this document, it also creates a new link type.

Yes, I use this process constantly. :slight_smile: