We value your input!
Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey

Archicad Python API
About automating tasks in Archicad using the Python API.
SOLVED!

Find unused viewpoints from Project Map?

MinhNguyen
Expert

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

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

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'')

 

 

View solution in original post

7 REPLIES 7

Yes, it is possible with python script. Script needs to check if view is created from viewpoint. 

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

Are you talking about this function:

 

https://bimdots.com/product/unused-view-cleaner/

Botonis Botonakis
Civil Engineer, Enviromental Design MSc., BIM Manager for BS ArhitectsVR
Company or personal website
Archicad 27. Windows 11. Intel Xeon 2699x2,64 GB RAM, Nvidia 3080Ti. 2 Monitors.
MinhNguyen
Expert

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

Ok..... That might be usefull also.

Botonis Botonakis
Civil Engineer, Enviromental Design MSc., BIM Manager for BS ArhitectsVR
Company or personal website
Archicad 27. Windows 11. Intel Xeon 2699x2,64 GB RAM, Nvidia 3080Ti. 2 Monitors.
Solution

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'')

 

 

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

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!