We value your input! Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey
2024-07-18 07:20 AM
Dear all,
I'm wondering if it's possible to find unused viewpoints from the Project Map? From GS there was a script for unused views (ones that are not placed in layouts or publisher set), my idea is to make a script that renames all unused viewpoints - one that has no view created. Does anyone have some idea on this? Any suggestion is greatly appreciated!
BIM Manager
DKO Architecture - HCMC
Solved! Go to Solution.
2024-07-18 09:30 AM - edited 2024-07-18 09:31 AM
This is the code I created for this purpose few years ago. I'm completely amateur in python, but it works for me.
from archicad import ACConnection
conn = ACConnection.connect()
assert conn
acc = conn.commands
act = conn.types
acu = conn.utilities
######## UnusedProjectMapItemsList ########
def isLinkNavigatorItem(item : act.NavigatorItem):
return item.sourceNavigatorItemId is not None
viewMapTree = acc.GetNavigatorItemTree(act.NavigatorTreeId('ViewMap'))
links = acu.FindInNavigatorItemTree(viewMapTree.rootItem, isLinkNavigatorItem)
sourcesOfLinks = set(link.sourceNavigatorItemId.guid for link in links)
projectMapTree = acc.GetNavigatorItemTree(act.NavigatorTreeId('ProjectMap'))
unusedProjectMapItems = acu.FindInNavigatorItemTree(projectMapTree.rootItem, lambda i: i.navigatorItemId.guid not in sourcesOfLinks )
unusedProjectMapItemsFiltered = []
for ii in unusedProjectMapItems:
isChildOfUnused = False
for jj in unusedProjectMapItems:
if ii != jj and acu.FindInNavigatorItemTree(jj, lambda node: node.navigatorItemId.guid == ii.navigatorItemId.guid):
isChildOfUnused = True
break
if not isChildOfUnused:
unusedProjectMapItemsFiltered.append(ii)
import datetime
JRAtime = datetime.datetime.now()
JRAtimestr = JRAtime.strftime("%Y")+"/"+ JRAtime.strftime("%m")+"/"+JRAtime.strftime("%d")+" "+ JRAtime.strftime("%X")
unusedProjectMapItemsCounter = 0
print('----- Unused Project Map Items List Start -----')
print('------------- ' + JRAtimestr+ ' -------------')
for unusedViewTreeItem in unusedProjectMapItems:
if unusedViewTreeItem.type == "UndefinedItem":
print( "\n" + unusedViewTreeItem.prefix +" "+ unusedViewTreeItem.name)
else:
print( "\t" + unusedViewTreeItem.prefix +" "+ unusedViewTreeItem.name)
unusedProjectMapItemsCounter += 1
print(f'')
print("----- Unused Project Map Items Counter:", unusedProjectMapItemsCounter, "-----")
print('------------------- List End --------------------')
print('-------------- ' + JRAtimestr+ ' --------------')
print(f'')
2024-07-18 07:35 AM
Yes, it is possible with python script. Script needs to check if view is created from viewpoint.
2024-07-18 07:40 AM
Is it possible for you to share some snippets of how you would do it? I followed the example script of moving unused views into a folder and successfully modified it into renaming unused views. Now I would like to apply the same logic for the viewpoints, but looks like it's not as easy as changing some parameters
BIM Manager
DKO Architecture - HCMC
2024-07-18 09:17 AM
Are you talking about this function:
https://bimdots.com/product/unused-view-cleaner/
2024-07-18 09:19 AM
Thanks, but unfortunately no, this program is similar to the Python script from GS to identify unused views. What I'm looking for is viewpoints in the Project Map, ones that have no views created from.
BIM Manager
DKO Architecture - HCMC
2024-07-18 09:22 AM
Ok..... That might be usefull also.
2024-07-18 09:30 AM - edited 2024-07-18 09:31 AM
This is the code I created for this purpose few years ago. I'm completely amateur in python, but it works for me.
from archicad import ACConnection
conn = ACConnection.connect()
assert conn
acc = conn.commands
act = conn.types
acu = conn.utilities
######## UnusedProjectMapItemsList ########
def isLinkNavigatorItem(item : act.NavigatorItem):
return item.sourceNavigatorItemId is not None
viewMapTree = acc.GetNavigatorItemTree(act.NavigatorTreeId('ViewMap'))
links = acu.FindInNavigatorItemTree(viewMapTree.rootItem, isLinkNavigatorItem)
sourcesOfLinks = set(link.sourceNavigatorItemId.guid for link in links)
projectMapTree = acc.GetNavigatorItemTree(act.NavigatorTreeId('ProjectMap'))
unusedProjectMapItems = acu.FindInNavigatorItemTree(projectMapTree.rootItem, lambda i: i.navigatorItemId.guid not in sourcesOfLinks )
unusedProjectMapItemsFiltered = []
for ii in unusedProjectMapItems:
isChildOfUnused = False
for jj in unusedProjectMapItems:
if ii != jj and acu.FindInNavigatorItemTree(jj, lambda node: node.navigatorItemId.guid == ii.navigatorItemId.guid):
isChildOfUnused = True
break
if not isChildOfUnused:
unusedProjectMapItemsFiltered.append(ii)
import datetime
JRAtime = datetime.datetime.now()
JRAtimestr = JRAtime.strftime("%Y")+"/"+ JRAtime.strftime("%m")+"/"+JRAtime.strftime("%d")+" "+ JRAtime.strftime("%X")
unusedProjectMapItemsCounter = 0
print('----- Unused Project Map Items List Start -----')
print('------------- ' + JRAtimestr+ ' -------------')
for unusedViewTreeItem in unusedProjectMapItems:
if unusedViewTreeItem.type == "UndefinedItem":
print( "\n" + unusedViewTreeItem.prefix +" "+ unusedViewTreeItem.name)
else:
print( "\t" + unusedViewTreeItem.prefix +" "+ unusedViewTreeItem.name)
unusedProjectMapItemsCounter += 1
print(f'')
print("----- Unused Project Map Items Counter:", unusedProjectMapItemsCounter, "-----")
print('------------------- List End --------------------')
print('-------------- ' + JRAtimestr+ ' --------------')
print(f'')
2024-07-18 09:37 AM
Wow, thank you so much! Worked like a charm for me! I think I know why mine doesn't work, I could use some idea in here for my project.
Thank you once again for the big help, much appreciated!
BIM Manager
DKO Architecture - HCMC