Hi Neil,
This AppleScript snippet might help you understand how BBEdit sees the
project document hierarchy.
set v4Spaces to " "
tell application "BBEdit"
set vProjectDocument to first project document
set vProjectCollections to project collections of vProjectDocument
repeat with vProjectCollection in vProjectCollections
my logProjectCollection(vProjectCollection, space)
end repeat
end tell
on logProjectCollection(aProjectCollection, aIndent)
tell application "BBEdit"
set vClass to (class of aProjectCollection) as string
if class of aProjectCollection is project collection then
log (aIndent & vClass & " 🗄: " & (name of
aProjectCollection) as string) & space
repeat with vSubProjectCollection in aProjectCollection
my logProjectCollection(vSubProjectCollection, aIndent
& my v4Spaces)
end repeat
return
else if class of aProjectCollection is project item then
set vPath to POSIX path of ((file of aProjectCollection) as
string)
else if aProjectCollection is not missing value then
set vPath to POSIX path of ((aProjectCollection) as string)
end if
if vPath ends with "/" then
set vType to "📁"
else
set vType to "📄"
end if
if vClass is "«class furl»" then
set vClass to "url"
end if
log aIndent & vClass & " " & vType & ": " & vPath & space
end tell
end logProjectCollection
HTH,
Jean Jourdain
On Friday, June 3, 2022 at 7:26:59 PM UTC+2 Neil Faiman wrote:
> BBEdit 14.1.2, Mac OS Monterey 12.4
>
> Using AppleScript, I want to navigate into a folder in a collection in a
> project window. I have the following script:
>
> *tell* *application* "BBEdit"
> *try*
> *set* project *to* *project document* "ZBA.bbprojectd"
> *on* *error*
> *display alert* ¬
> "The ZBA project is not open in BBEdit" as *warning* message ¬
> "Open the ZBA project and try again" buttons "OK" default button "OK"
> *return*
> *end* *try*
> *set* site *to* project's *project collection* "Site"
> *set* cases *to* site's *first* *project item* *whose* name *is* "cases"
> *end* *tell*
>
> Debugging it in ScriptDebugger, the "*set* project” command successfully
> accesses the project, and sets project to a BBEdit *project document* object.
> When I examine it in the debugger, it contains a dozen *project
> collection* elements. *project collection 10* is named “Site” and
> represents a folder on disk. However, after executing the “*set* site”
> command, site is *not* a BBEdit *project collection* object — it is a
> file reference to the folder represented by the collection ( «class file»
> "Macintosh HD:Users:neil:Library:Mobile
> Documents:com~apple~CloudDocs:zba:Web Site:wiltonzba.org:" ).
>
> Can anyone explain this behavior, or, even better, how to get at the *project
> collection* (and its contents0 as I intended?
>
> Thanks,
> Neil Faiman
>
>
>
>
--
This is the BBEdit Talk public discussion group. If you have a feature request
or need technical support, please email "[email protected]" rather than
posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/bbedit/00f1b217-7a97-4ce7-a874-3e5ae8d3cc36n%40googlegroups.com.