[Ma...] Posted November 26 Share Posted November 26 Hi, i am working on removal of magnets based on ref. points - i am using select inside sphere. Script is running ok, but i wanted to remove that from measurement instead from polygonized model -> i've solved. To block removing selection i wanted to use "gom.app.project.parts[0].actuals.selected_area" which is not working properly - it's saying 0.0 when is mesh polygonized and selection is on measurement. Bug part: But if nothing is selected, then whole Inspect is crashing. Using "try - exception" is not helping. Is there a command to get selected area globally? Not just mesh. Thanks Link to comment Share on other sites More sharing options...
[Ma...] Posted November 26 Author Share Posted November 26 Edit to topic: it fails in this case. ... How big is selected area Remove selected How big is selected area -> crash Is there a way how to see if its pre-mesh? I can not find any information if polygonization was done Link to comment Share on other sites More sharing options...
[De...] Posted November 27 Share Posted November 27 Hey martin, could you post your code? you might want to try and use if gom.app.project.parts[0].actuals.selected_area > 0.0: delete else: ?? Dialog - manual selection / increase radius / continue... ?? Since that keyword (.selected area) isnt available for the individual measurements, i'd recommend just selecting the mesh, deleting what you need to delete, then let it recalculate. hope it helps. Link to comment Share on other sites More sharing options...
[Ma...] Posted November 27 Author Share Posted November 27 I'll try tomorrow post a code with some description. You are right with selected_area and that's what i have there, but sometimes app crashes and sometimes not. I was attempting to either remove that selection from measurement or polygonized model - both variants are working. But sometimes it crashes and i can not find why. Reason for doing it before polygonization - after polygonization it's back. I would rather have and option to know when is model polygonized, otherwise it's no use to do it on pre-mesh. In sketch -> i do exclusively show only measurement mesh to have right selection, then removing selected area. Or depending on condition it's exclusively shown polyg. mesh and selection is on that mesh. Before anything i store visible things and after removal i restore visible again. Link to comment Share on other sites More sharing options...
[Ma...] Posted November 28 Author Share Posted November 28 OK so here it is. If i would have something to know in which state is a mesh, it would be great - i would set this script for polygonized mesh only. # -*- coding: utf-8 -*- ''' Author: Jánský Martin Date : 2025-11-26 Description: Selection of mesh as sphere from reference points Selection from measurement or computed mesh ''' import gom # Storing visible state / missing measured filters - TODO STAV = gom.ElementSelection( {'category':['key','elements', 'explorer_category', 'nominal_part']}, {'category':['key','elements', 'explorer_category', 'actual_part']}, {'category':['key','elements', 'explorer_category', 'measurements']}, {'category':['key','elements', 'explorer_category', 'nominal']} #, filter = {'type' : 'visible'} ) STAV_LIST = [] for x in STAV: if x.is_visible == True: STAV_LIST.append(x) # ensure non is selected before gom.script.selection3d.deselect_all () # getting measurement series info MEASUREMENT = gom.ElementSelection ({'category': ['key', 'elements', 'explorer_category', 'measurements', 'object_family', 'measurement_series']}) MEAS_LIST = [] # storing list of ref. points for MEAS_SERIE in MEASUREMENT: print("Measurement serie:", MEAS_SERIE) print("Number of ref. points:", MEAS_SERIE.results['points'].num_points) MEAS_LIST.append(MEAS_SERIE) # 1st try for a condition of polygonized mesh or pre-mesh MESH_status = gom.app.project.parts[0].actual.computation_status print("MESH status:", MESH_status) if MESH_status != "computed": # show only model from measurement gom.script.cad.show_element_exclusively (elements=gom.ElementSelection ({'category': ['key', 'elements', 'is_element_in_clipboard', 'False', 'part', '', 'explorer_category', 'measurements']})) else: # show only polygonized mesh - possible error when there is no mesh / next not tested - selected CAD? gom.script.cad.show_element_exclusively (elements=gom.ElementSelection ({'category': ['key', 'elements', 'part', gom.app.project.parts[0]]})) # selection of a mesh based on ref. points for _m in MEAS_LIST: for x in range(0,_m.results['points'].num_points): pos = _m.results['points'].coordinate[x] gom.script.selection3d.select_inside_sphere ( center={'point': pos}, radius=13.0) # deselection of ref. points - sometimes it was removing ref. points from measurement gom.script.selection3d.deselect_all_points_of_element (elements=[_m.results['points']]) # 1st try for a condition of polygonized mesh or pre-mesh if gom.app.project.parts[0].actual.computation_status != "computed": gom.script.cad.delete_selected_3d_area (reset_deviation_values=True) elif gom.app.project.parts[0].actual.selected_area > 0.0: # here is surelly high risk condition, which crashed even just by clicking in import dialog print('Selected area:',gom.app.project.parts[0].actual.selected_area) gom.script.cad.delete_selected_3d_area (reset_deviation_values=True) else: print('Selected area:',gom.app.project.parts[0].actual.selected_area) # deselect for case there was no removing gom.script.selection3d.deselect_all () # recovering visible state gom.script.cad.show_element_exclusively(elements=STAV_LIST)  Link to comment Share on other sites More sharing options...
[Na...] Posted November 28 Share Posted November 28 Hi Martin, I did not analyse this yet but why could you not use the cutout parameters of the reference points? The function is already built in so need for scripting usually. If there is some functionally missing it might be interesting for which application this is needed 🙂  Link to comment Share on other sites More sharing options...
[Ma...] Posted November 28 Author Share Posted November 28 Please sign in to view this username. Hi, we are using magnets with sticked ref. point ( just to speedup measurement at low cost ). Those are not perfect made ( different thickness, not-centered ) and after scanning we are having problems with removing them. Sometimes there is face of a magnet, sometimes some residues of cylinder. We are using them on non critical places and they are just to keep tracking on our steel forms. Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in