How to get a scene for each selected element using python in cadwork? #131
-
Based on the code from the Cadwork API documentation, I have created the code below. My intention is to obtain a scene for each selected element. However, when I select multiple elements, it currently creates a scene for each one. Unfortunately, the content of each scene includes all the elements instead of having each element in a separate scene.
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
hey, you have to set the elements inactive.
|
Beta Was this translation helpful? Give feedback.
-
We will check this behaviour, looks like an unexpected behaviour. As an import element_controller as ec
import scene_controller as sc
import visualization_controller as vc
def main():
element_ids = ec.get_active_identifiable_element_ids()
vc.set_inactive(element_ids) # this should not be necessary in the future (bug)
print(f"{len(element_ids)} active elements.")
for index, element_id in enumerate(element_ids):
scene_name = f"Scene {index}"
if sc.add_scene(scene_name):
sc.add_elements_to_scene(scene_name, [element_id])
if __name__ == '__main__':
main() |
Beta Was this translation helpful? Give feedback.
-
The function corresponds to the standard behaviour of cadwork. |
Beta Was this translation helpful? Give feedback.
We will check this behaviour, looks like an unexpected behaviour. As an
List[elementId]
is explicitly passed as a parameter, only this should be added to the scene.