I’m working on a script to modify VisualArq Section Attributes according to their layer name. Here is my current method:
def apply_section_attributes_by_layer_name(material_name, pattern, pattern_scale, pattern_angle, line_weight):
selected_objs = []
all_objs = rs.AllObjects()
if all_objs:
rs.EnableRedraw(False)
for obj in all_objs:
obj_layer = rs.ObjectLayer(obj)
if material_name in obj_layer:
selected_objs.append(obj)
if selected_objs:
for obj in selected_objs:
va.SetObjectSectionPattern(obj, pattern, pattern_angle, pattern_scale)
va.SetObjectSectionPlotWeight(obj, line_weight)
I would like to also apply these changes to objects contained in blocks, so I’m guessing something recursive should happen to BlockEdit each block, run the method, and then go to next block, etc. I usually avoid working with nested blocks.
This topic is looking for the same result, but it makes me think it is not possible at the moment:
Still, I wanted to ask here, in order to know if it could be made.
I hope my request is clear enough, I can elaborate if you need me to.
Thank you,
For anyone interested, here is my updated code, working but still needs some testing
def apply_section_attributes_by_layer_name(material_name, pattern, pattern_scale, pattern_angle, line_weight):
selected_objs = []
all_objs = rs.AllObjects()
if all_objs:
rs.EnableRedraw(False)
for obj in all_objs:
obj_layer = rs.ObjectLayer(obj)
if material_name in obj_layer:
selected_objs.append(obj)
if selected_objs:
for obj in selected_objs:
va.SetObjectSectionPattern(obj, pattern, pattern_angle, pattern_scale)
va.SetObjectSectionPlotWeight(obj, line_weight)
idefs = sc.doc.InstanceDefinitions
for idef in idefs:
idef_objects = idef.GetObjects()
for obj in idef_objects:
obj_id = obj.Id
obj_layer = rs.ObjectLayer(obj)
if material_name in obj_layer:
va.SetObjectSectionPattern(obj_id, pattern, pattern_angle, pattern_scale)
va.SetObjectSectionPlotWeight(obj_id, line_weight)