3 weeks ago - last edited 3 weeks ago
Hi All
Is there a way to find unused layer combinations?
How can I check which layer combo is used for View Map item?
I don't see any command I could use.
Thank you
Solved! Go to Solution.
3 weeks ago
Hello Piotr,
The 1.1.4. relese of the Tapir archicad addon has just intruduced the GetViewSettings command that returns the name of the associated layer combination for each NavigatorItemId.
There seams to be something off with the documentation for this command, so I'll paste the schema from the source here:
{
"name": "GetViewSettings",
"version": "1.1.4",
"description": "Gets the view settings of navigator items",
"inputScheme": {
"type": "object",
"properties": {
"navigatorItemIds": {
"$ref": "#/NavigatorItemIds"
}
},
"additionalProperties": false,
"required": [
"navigatorItemIds"
]
},
"outputScheme": {
"type": "object",
"properties": {
"viewSettings": {
"type": "array",
"item": {
"type": "object",
"description": "The settings of a navigator view or an error.",
"oneOf": [
{
"$ref": "#/ViewSettings"
},
{
"$ref": "#/ErrorItem"
}
]
}
}
},
"additionalProperties": false,
"required": [
"viewSettings"
]
}
}
"ViewSettings": {
"type": "object",
"description": "The settings of a navigator view",
"properties": {
"modelViewOptions": {
"type": "string",
"description": "The name of the model view options. If empty, the view has custom model view options."
},
"layerCombination": {
"type": "string",
"description": "The name of the layer combination. If empty, the view has custom layer combination."
}
},
"additionalProperties": false,
"required": []
}
I think the official JSON commands should cover the rest (API.GetNavigatorItemTree can get you the NavigatorId-s of all views)
3 weeks ago
Hello Piotr,
The 1.1.4. relese of the Tapir archicad addon has just intruduced the GetViewSettings command that returns the name of the associated layer combination for each NavigatorItemId.
There seams to be something off with the documentation for this command, so I'll paste the schema from the source here:
{
"name": "GetViewSettings",
"version": "1.1.4",
"description": "Gets the view settings of navigator items",
"inputScheme": {
"type": "object",
"properties": {
"navigatorItemIds": {
"$ref": "#/NavigatorItemIds"
}
},
"additionalProperties": false,
"required": [
"navigatorItemIds"
]
},
"outputScheme": {
"type": "object",
"properties": {
"viewSettings": {
"type": "array",
"item": {
"type": "object",
"description": "The settings of a navigator view or an error.",
"oneOf": [
{
"$ref": "#/ViewSettings"
},
{
"$ref": "#/ErrorItem"
}
]
}
}
},
"additionalProperties": false,
"required": [
"viewSettings"
]
}
}
"ViewSettings": {
"type": "object",
"description": "The settings of a navigator view",
"properties": {
"modelViewOptions": {
"type": "string",
"description": "The name of the model view options. If empty, the view has custom model view options."
},
"layerCombination": {
"type": "string",
"description": "The name of the layer combination. If empty, the view has custom layer combination."
}
},
"additionalProperties": false,
"required": []
}
I think the official JSON commands should cover the rest (API.GetNavigatorItemTree can get you the NavigatorId-s of all views)
3 weeks ago
Thank you SzamosiMate, that looks promising. I'll check it next week.
Friday
Thank you again — GetViewSettings command worked well. Also, thanks to every Tapir contributor.
Do you think it's possible to check whether a layer is visible in the view when using a custom layer combo?
Saturday
@Piotr Walerysiak Have this worked for you?
Saturday
Currently GetViewSettings does not return this information, but it is avalible from the C++ API, so it should not be too difficult to change the command to include this informaton.
If you'd like to use it in a workflow, please ask for it on the Tapir Discord, or open an Issue on Github. (https://github.com/ENZYME-APD/tapir-archicad-automation)
Thinking about it, with this, and a possible future CreateLayerCombinations Command you could scan all views, and for all "custom" views find the corresponding layer combination and set it for the view, or if none exist create one in a separate folder that the user can check and decide what to do with it.
That seams like a wortwhile thing
yesterday
Yes, that worked. Here's my code:
from archicad import ACConnection
conn = ACConnection.connect()
assert conn
acc = conn.commands
act = conn.types
acu = conn.utilities
response = acc.ExecuteAddOnCommand (act.AddOnCommandId ('TapirCommand', 'GetAddOnVersion'))
print (f'Tapir {response}')
########## GetLayerCombinationList ##########
layerComboAttr = acc.GetLayerCombinationAttributes(acc.GetAttributesByType("LayerCombination"))
layerComboNameList = [layercombolists.layerCombinationAttribute.name for layercombolists in layerComboAttr]
######## Get ViewMapTree and ViewGuids ########
def isViewNavigatorItem(item : act.NavigatorItem):
return item.type != None and item.type != 'FolderItem'
viewMapTree = acc.GetNavigatorItemTree(act.NavigatorTreeId('ViewMap'))
viewmap = acu.FindInNavigatorItemTree(viewMapTree.rootItem, isViewNavigatorItem)
viewGuids = [{'navigatorItemId': viewmaps.navigatorItemId.to_dict()} for viewmaps in viewmap]
######### ViewLayerCombinationList #########
### Get View Settings (Tapir command)
viewSettings = acc.ExecuteAddOnCommand(
act.AddOnCommandId('TapirCommand', 'GetViewSettings'),
{"navigatorItemIds": viewGuids }
)
viewSettings = viewSettings.get('viewSettings')
allViewSettingsLayerComboNameList = []
for viewSetting in viewSettings:
if viewSetting.get('layerCombination') != None:
allViewSettingsLayerComboNameList.append(viewSetting.get('layerCombination'))
### Filter ViewLayerCombinationNames
usedLayerComboList = []
for usedLayerCombo in allViewSettingsLayerComboNameList:
if not usedLayerCombo in usedLayerComboList:
usedLayerComboList.append(usedLayerCombo)
######### UnusedLayerCombinationList #########
unusedLayerComboList = []
for layerCombo in layerComboNameList:
if not layerCombo in usedLayerComboList:
unusedLayerComboList.append(layerCombo)
unusedLayerComboList.sort()
unusedLayerComboListStr = ""
for unusedLayerCombo in unusedLayerComboList:
unusedLayerComboListStr += f'{unusedLayerCombo}\n'
print(f'\nUnused Layer Combinations:\n{unusedLayerComboListStr}')