[Ma...] Posted November 26 Share Posted November 26 Good morning to all, I have to get the position in the active 3d view of a label. With a dn label this is possible, but with a normal label it seems that it's not possible (the result is None). I am wrong with something? Link to comment Share on other sites More sharing options...
[Ma...] Posted November 26 Author Share Posted November 26 If found the bug: if you just visualize the label, the offset posizion in 3d view is None, if you move the label the property "label_offset_in_3d_view" start to work. I attach a video about this that I think i't a bug. GOMSoftware_pHeRErwJac.mp4 Link to comment Share on other sites More sharing options...
[Ma...] Posted November 27 Share Posted November 27 Hi Marco, Which version (incl. service-pack) of ZEISS INSPECT are you using? Thank you and best regards, Matthias Link to comment Share on other sites More sharing options...
[Ma...] Posted November 27 Author Share Posted November 27 (edited) GOM Inspect (2021 Hotfix 9, Rev. 157193, Build 2022-12-08) Edited November 27 Link to comment Share on other sites More sharing options...
[Ma...] Posted December 4 Author Share Posted December 4 Anyone has an idea? Link to comment Share on other sites More sharing options...
[Ma...] Posted December 5 Share Posted December 5 Sorry, I don't have this version available for testing any more. Link to comment Share on other sites More sharing options...
[Ma...] Posted December 9 Author Share Posted December 9 With your gom versione don't you have this problem? Link to comment Share on other sites More sharing options...
[De...] Posted December 9 Share Posted December 9 maybe try to select that element with the script? https://zeiss.github.io/zeiss-inspect-app-api/2025/howtos/python_api_introduction/selecting_elements.html Link to comment Share on other sites More sharing options...
[Na...] Posted December 10 Share Posted December 10 Hi Marco, I think this is a feature. The offset only exists, if the label was moved from its original 'standard' position. Link to comment Share on other sites More sharing options...
[Ma...] Posted Friday at 03:39 PM Author Share Posted Friday at 03:39 PM Hi Nanno! My goal is to take the vector and the position in the 3dview of a dn label then create a normal deviation label in the same position of the dn label. Do you know the right way to do it? Link to comment Share on other sites More sharing options...
[De...] Posted Friday at 05:58 PM Share Posted Friday at 05:58 PM hey marco, to clarify - you want a nominal surface point with dn check instead of a deviation label on the surface comparison? import gom import numpy as np gom_part = gom.app.project.parts[0] label = gom.app.project.inspection['Surface comparison 2'].deviation_label['Surface comparison 2.1'] coord = np.array(label.data.coordinate) normal = np.array(label.data.normal) x, y, z = coord.reshape(-1) nx, ny, nz = normal.reshape(-1) gom.script.cad.show_element_exclusively (elements=gom.ElementSelection ({'category': ['key', 'elements', 'part', gom_part, 'explorer_category', 'nominal_part']})) ##nominal surface pt nominal_surface_pt = gom.script.primitive.create_surface_point ( name_expression='Point_from_label', point={'interpolated': True, 'normal': gom.Vec3d (nx, ny, nz), 'point': gom.Vec3d (x,y,z), 'target': gom_part}) ##make sure its attached to cad surface gom.script.cad.adapt_elements_to_cad ( elements=[nominal_surface_pt], normal_from_cad=True, position_from_cad=True) ##mp MCAD_ELEMENT=gom.script.inspection.measure_by_intersection_with_mesh ( elements=[nominal_surface_pt]) #check MCAD_ELEMENT=gom.script.inspection.inspect_dimension ( csys=gom.app.project.nominal_elements['system_global_coordinate_system'], elements=[nominal_surface_pt], nominal_value=0.0, nominal_value_source='fixed_value', type='normal') Link to comment Share on other sites More sharing options...
[Ma...] Posted Monday at 08:34 AM Author Share Posted Monday at 08:34 AM No, viceversa: I want to create a normal label deviation instead of a dn point check. But don't worry, I try to adapt you code for my situation. Thank you very much! Link to comment Share on other sites More sharing options...
[Ma...] Posted Monday at 01:05 PM Author Share Posted Monday at 01:05 PM But my problem is not to create the label, but put it in the correct position in the space, because my goal is to restore a view in the 3D view, create the label instead of the dn label, hide it and then overwrite the view in the report. Link to comment Share on other sites More sharing options...
[De...] Posted Monday at 05:19 PM Share Posted Monday at 05:19 PM ah, label position in 3d view. thats a tough one, you could prob use that apply selection function + label offset in 3d view to get the gom.Vec3d, but i'm not sure theres a function to then set that attribute. I tried for label in gom.ElementSelection ({'category': ['key', 'elements', 'part', gom_part, 'explorer_category', 'inspection', 'object_family', 'deviation_label', 'type', 'deviation_label_surface']}): gom.script.explorer.apply_selection(selection = [label]) print(label.label_offset_in_3d_view) gom.script.sys.edit_properties ( data=[label], label_show=True, label_offset_in_3d_view = gom.Vec3d (5.29687008412543, 2.842170943040401e-14, -7.7582401624698605) ) which prints all the positions, but doesnt work for setting a new position. maybe throw em all to screen edge? Link to comment Share on other sites More sharing options...
[Ma...] Posted Tuesday at 07:42 AM Author Share Posted Tuesday at 07:42 AM This is the code I use, but for some label it doesn't work. I don't know why. What command I can use to put them, if label offset is None, to the screen edge? def dn_in_label(): #Pulizia report pagine_da_pulire_lst=[] for pagina_da_pulire in gom.app.project.reports: pagine_da_pulire_lst.append(pagina_da_pulire) gom.script.report.update_report_page ( pages=pagine_da_pulire_lst, used_alignments='report', used_digits='report', used_legends='report', used_stages='current', used_units='report') reports = gom.app.project.reports for report in reports: print(report) pages = report.pages for page in pages: print(page) elements = page.elements for element in elements: print(element) if element.get('type') == 'figure_snapshot_frame': componente = element.parts_in_report print(componente) # stampa il valore di 'componente' part = gom.app.project.parts[componente] gom.script.report.restore_3d_view_from_report_page(page=element) visible_dn_lst = [] visible_measure_lst=[] # Filtra i punti che contengono ".dN" e sono visibili for dn in gom.app.project.inspection: print (dn) print (dn.scalar_value) if ".dN" in dn.name: if dn.is_visible: visible_dn_lst.append(dn) if dn.scalar_value is not None and dn.scalar_value > 0: if dn.is_visible: visible_measure_lst.append(dn) print (visible_measure_lst) gom.script.cad.hide_element (elements=visible_measure_lst) # Per ogni punto dN visibile for dn in visible_dn_lst: coordinata_dn = dn.center_coordinate normale_dn = dn.normal dn_pos = dn.label_offset_in_3d_view # Per ogni confronto superficie visibile for confronto in gom.app.project.inspection: print (confronto) if confronto.get('type') == 'surface_comparison' and confronto.is_visible: print(confronto) # Chiamata allo script per ogni coppia punto/confronto MCAD_ELEMENT = gom.script.inspection.inspect_by_deviation_label(point={'interpolated': True, 'normal': normale_dn, 'point': coordinata_dn, 'target': confronto}) gom.script.cad.hide_element (elements=[dn]) label=MCAD_ELEMENT print (label) gom.script.sys.edit_properties ( data=gom.ElementSelection (label, {'attachment_group': [None, 'criterias']}), elem_show=True, label_show=True, label_template='Annotazione di Deviazione', label_template_uuid='3807e37f-a68f-4bed-b65c-61f0ddd1000c') gom.script.cad.set_label_position(elements=[label],offset=dn_pos) gom.script.sys.switch_to_report_workspace() gom.script.report.overwrite_report_page(target=element) Link to comment Share on other sites More sharing options...
[De...] Posted Tuesday at 06:36 PM Share Posted Tuesday at 06:36 PM hmm, didnt know that was a function, (would be nice if we had a global list of these things somewhere) for labels on screen edge: gom.script.cad.set_label_distribution_mode (distribution_mode='border') try and drop the s) from elements, and dont use a list. docstring is kinda confusing, try and just use the arguments (element & offset) print(gom.script.cad.set_label_position.__doc__) cad.set_label_position (Move Label) - Move Label Parameters: Name | Description | Type | Optional -------------------------------------------------------------------------------------------------------------------------- element | defines the name of the element | Tom::Reference | No elements | defines the names of the elements | Tom::MCADCmd::Traits::ElementSelection | No position | defines the position of the label | Core::Types::BaVec<2,double> | No offset | defines the 3d offset of the label | Core::Types::BaVec<3,double> | No offsets | defines the 3d offset of the label | QVariantList | No view_index | defines the index of the view, where the label gets moved | uint | Yes position seems to be is in lieu of offset (?)- or atleast thats what the error said when I tried to use it. gom_part = gom.app.project.parts[0] for label in gom.ElementSelection ({'category': ['key', 'elements', 'part', gom_part, 'explorer_category', 'inspection', 'object_family', 'deviation_label', 'type', 'deviation_label_surface']}): gom.script.explorer.apply_selection(selection = [label]) print(label.label_offset_in_3d_view) gom.script.cad.set_label_position( element=label, # position = gom.Vec2d(15,25), offset=gom.Vec3d (20,-20,-20) ) ^^seems to work like the 'justify label' button anyways, good luck! Link to comment Share on other sites More sharing options...
[Ma...] Posted 5 hours ago Author Share Posted 5 hours ago Thank you very much! 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