Hello!
Do you notice anything wrong with my script?
I can see that I am inputing exactly the group and attached detail group that I want. The final output results in null, but it does not show any warning. And it doesn’t change anything in the model, obviously.
I can’t figure out what the problem is.
I ran into the same problem. So I checked the API docs and for what I can find is the “.ShowAttachedDetailGroups Method” a method that is only available for Revit 2020. So I’m curious how @Bjorn_Keulemans1 got his script working in Revit 2019. https://www.revitapidocs.com/2020/2e4d7640-92fa-fc3b-83a2-e492bc8b0269.htm (link to ShowAttachedDetailGroups Method in the API docs)
Hi,
I added a screenshot of my script. It doesn’t work, but i can’t find why. I tried changing the lacing, creating a for loop around the loop wich apply’s the attached detail groups and tried using a single view group and detail group combination that should’ve worked, None of them worked. I checked my revit verson and I am running Revit 2019.2.
The reason why it does not work is in the description of the Node.
It is set up to do 1 Detail Group each for Multiple Model Groups in 1 View. Check the link earlier in the topic for my example script. I’ve set it up this way for my own workflows where I control the Annotations in a master plan and all the unit plans are dependant views from that plan.
It looks like you want to do 1 Detail Group in 1 Model Group in 1 View each, so you should alter the Python code. This should work:
import clr
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
modelGroups = UnwrapElement(IN[0])
detailGroups = UnwrapElement(IN[1])
views = UnwrapElement(IN[2])
doc = DocumentManager.Instance.CurrentDBDocument
TransactionManager.Instance.EnsureInTransaction(doc)
for m,d,v in zip(modelGroups,detailGroups,views):
m.ShowAttachedDetailGroups(v,d.Id)
TransactionManager.Instance.TransactionTaskDone()
#Assign your output to the OUT variable.
OUT = IN[0]
This is what i need also (need to turn them off again later, hence my previous question).
I replaced the Python code with the code in the above post, but it doesn’t work.
Am i doing something wrong?
The code above was for 1 Model Group - 1 Detail Group in 1 View EACH. Not the same view, it expects a list of views.
Your case look like my original use case where I control the Detail Groups in 1 View for multiple Model Groups. You might want to take a look at the original version.
You can probably also fix this by List.Count and List.OfRepeatedItem to make a list of your View the same length as the others.
I’ve been struggling with the different use cases for this workflow and how to catch all of those without demanding insane list structures from the users.
Is it a lot of MG with 1 DG each in 1 view, is it multiple MG with multiple each in 1 view, is it multiple MG with 1 different DG in different Views etc. Someone a lot more experienced in Python can probably handle that a lot better.
To answer your question. I have a bunch of apartments on multiple levels and in multiple buidlings (in the same model). I need to make a View for every apartment (i already made a script for that) and need to turn on the attached Detail Group for each of those Views. Some Views will have the same apartment (type) but are on a different level and / or building.
and when that didn’t work I tried changing it to make the for loop inside a for loop:
TransactionManager.Instance.EnsureInTransaction(doc)
for i in views:
for m,d in zip(modelGroups,detailGroups):
m.ShowAttachedDetailGroups(i,d.Id)
TransactionManager.Instance.TransactionTaskDone()
That didn’t work eighter… So I think it has something to do with my list management.
What I want it to do is make DG with te prefix UO- show in all floorplans I specify.