Friday
- last edited
Saturday
by
Laszlo Nagy
Hi to all!
I have a lot of layouts with PDF inserted.
Is there any way to replace the name of the layout with the hosted single name drawing (PDF) in?
Attached image to explain it
Thanks in advanced.
JCG
Operating system used: Windows 24H2
Solved! Go to Solution.
Sunday
@cagarruta schrieb:
I have a lot of layouts with PDF inserted.
Is there any way to replace the name of the layout with the hosted single name drawing (PDF) in?
That's possible with Python.
The following script will rename all Layouts in a given folder (change it before running obviously) to their first placed drawing.
Caveat: It is currently impossible to tell what kind of drawing is placed on a layout! So this will cover internal drawings just as well as external PDFs.
That's why it's needed to restrict this to a given folder. It's also undoable. So please beware.
import archicad
try:
conn = archicad.ACConnection.connect()
assert conn
acc = conn.commands
act = conn.types
acu = conn.utilities
except AssertionError:
raise RuntimeError("No Archicad instance running!")
subset_name = "MY FOLDERNAME"
# rename : ^^^^^^^^^^^^
# *****************************#
layoutBookTree = acc.GetNavigatorItemTree(act.NavigatorTreeId("LayoutBook"))
# get the approppiate Folder:
subset_itemList = acu.FindInNavigatorItemTree(
layoutBookTree.rootItem, lambda node: node.name == subset_name
)
# The following gives not the subset as-is, but instead a list of
# discrete 'NavigatorItemArrayItem's (sic)...
for item in subset_itemList[0].children:
# is a Drawing placed?
if item.navigatorItem.children is not None:
acc.RenameNavigatorItem(
item.navigatorItem.navigatorItemId,
item.navigatorItem.children[0].navigatorItem.name,
)
Sunday
@cagarruta schrieb:
I have a lot of layouts with PDF inserted.
Is there any way to replace the name of the layout with the hosted single name drawing (PDF) in?
That's possible with Python.
The following script will rename all Layouts in a given folder (change it before running obviously) to their first placed drawing.
Caveat: It is currently impossible to tell what kind of drawing is placed on a layout! So this will cover internal drawings just as well as external PDFs.
That's why it's needed to restrict this to a given folder. It's also undoable. So please beware.
import archicad
try:
conn = archicad.ACConnection.connect()
assert conn
acc = conn.commands
act = conn.types
acu = conn.utilities
except AssertionError:
raise RuntimeError("No Archicad instance running!")
subset_name = "MY FOLDERNAME"
# rename : ^^^^^^^^^^^^
# *****************************#
layoutBookTree = acc.GetNavigatorItemTree(act.NavigatorTreeId("LayoutBook"))
# get the approppiate Folder:
subset_itemList = acu.FindInNavigatorItemTree(
layoutBookTree.rootItem, lambda node: node.name == subset_name
)
# The following gives not the subset as-is, but instead a list of
# discrete 'NavigatorItemArrayItem's (sic)...
for item in subset_itemList[0].children:
# is a Drawing placed?
if item.navigatorItem.children is not None:
acc.RenameNavigatorItem(
item.navigatorItem.navigatorItemId,
item.navigatorItem.children[0].navigatorItem.name,
)
Sunday
Thanks so much, Runxel.
I've been meaning to learn Python to use with Archicad, and I think the time has come.
Sunday
- last edited
12 hours ago
by
Laszlo Nagy
Awesome Runxel!!
it works at first time!
thanks a lot!