@ONO and @gokermu, I didn’t know, but I dug into this a little.
Views and Sheets are all stored in Speckle as Object.BuiltElement.View
or Objects.BuiltElements.View:Objects.BuiltElements.View3D
for 3D views.
We send both Views and sheets as individual objects and not nested one in the other because while views can only exist on one sheet, there can be views in your file that are not placed on sheets.
Instead, you can link them with the Sheet Number:
Category Sheets have a property under data.parameters.SHEET_NUMBER
; there are also parameters for discipline and phase and other properties you might have set for the Project Explorer organisation.
Category Views also have a property data.parameters.VIEWPORT_SHEET_NUMBER
along with many other standard and custom parameters that you may have set.
So, to list just Sheets, it will be as you have set in your question, but I’ve added some extra to focus the results :
query GetSheets($projectId: String!,
$versionRefencedObjectId: String!,
$sheets_select: [String],
$sheets_query: [JSONObject!]) {
stream(id: $projectId) {
object(id: $versionRefencedObjectId) {
children(query: $sheets_query, select: $sheets_select) {
objects {
data
}
}
}
}
}
with variables:
{
"projectId": "08068f03a5",
"versionRefencedObjectId": "29921e44a3d85c294f10262ae290b570",
"sheets_query": [
{
"field": "category",
"operator": "=",
"value": "Sheets"
}
],
"sheets_select": [
"category",
"parameters.SHEET_NUMBER.value",
"parameters.SHEET_NAME.value"
]
}
leading to:
But you had that already.
A views-appearing-on-sheets query would be:
query GetViews($projectId: String!, $views_select: [String], $versionRefencedObjectId: String!, $views_query: [JSONObject!]) {
stream(id: $projectId) {
object(id: $versionRefencedObjectId) {
children(query: $views_query, select: $views_select) {
objects {
data
}
}
}
}
}
with variables:
{
"projectId": "08068f03a5",
"versionRefencedObjectId": "29921e44a3d85c294f10262ae290b570",
"views_query": [
{
"field": "category",
"operator": "=",
"value": "Views"
},
{
"field": "parameters.VIEWPORT_SHEET_NUMBER.value",
"operator": "!=",
"value": "void"
}
],
"views_select": [
"category",
"parameters.VIEW_FAMILY_SCHEDULES.value",
"parameters.Unterdisziplin.value",
"parameters.VIEWPORT_SHEET_NUMBER.value",
"parameters.VIEW_DESCRIPTION.value",
"parameters.PLAN_VIEW_LEVEL.value"
]
}
The field != void
trick will filter out any view not placed on a sheet. The value void
could equally be banana
or an empty string ""
, but that’s just my habit of making the action explicit.
If, instead, you want to get Views for a specific sheet, you can pass the value of one of the Sheets captured earlier and change the operator to "="
"views_query": [
{
"field": "category",
"operator": "=",
"value": "Views"
},
{
"field": "parameters.VIEWPORT_SHEET_NUMBER.value",
"operator": "=",
"value": "TGA-HZG-LPH 5-01"
}
],