0
Completed

Selecting Vizex Objects in Scripts?

Geoff Elson 9 years ago in Scripting updated by Yan 9 years ago 4
I have recorded processes performed in the vizex window but when I look at the .py code what I have selected in vizex just comes through as...

#Select Tool
MMpy.Command("#33746").run()

How do you pass specific objects to this command in the code and then run subsequent commands. In particular I am trying to select wireframes.

Thanks,
Geoff
Under review
Hi Geoff,

Right now, there is no easy way to select a specific object in Vizex. What you can do is try to load a selection by condition formset to select your wireframe. Here is a quick example:

formset = MMpy.FormSet("WS_LOAD_POINTS","15.0.0.0")
#load the point form set id 900
formset.load(900)
selection_condition = MMpy.FormSet("WS_SELECTION_CONDITION","15.0.0.0")
# load the select_condition formset id 2 from the user database
selection_condition.open(2, MMpy.StorageType.user) #this will print a dictionnary of the fields name and corresponding values
print(selection_condition.get())
selection_condition.run()
Let me know if that help.

Just tested it and there is still some limitation, for now the selection by condition will select everything that is loaded in Vizex, despite of the condition. I'll see if there is something we can do to simply select something in Vizex
+1
Geoff,

In the next version of Micromine, you are going to be able to record the selection by condition dialog and edit the fields to select anything you like in Vizex. Here is a partial example, where we select 2 string, build a wireframe using the interactive tool:

...
WsLoadStrings_FormSet1.set_field("WSSTR_FILE","UG_Tunnel")
WsLoadStrings_FormSet1.run("Tunnel_Strings")

WsSelectionCondition_FormSet2= MMpy.FormSet("WS_SELECTION_CONDITION","15.0.0.395")
DataGrid1 = MMpy.DataGrid(5,1)
DataGrid1.set_column_info(0,1,16)
DataGrid1.set_column_info(1,2,16)
DataGrid1.set_column_info(2,3,6)
DataGrid1.set_column_info(3,4,-1)
DataGrid1.set_column_info(4,5,14)

WsSelectionCondition_FormSet2.set_field("GRID",DataGrid1.serialise())
WsSelectionCondition_FormSet2.set_field("VIEW_SELECTION","0")
WsSelectionCondition_FormSet2.set_field("SEL_SELECTION","0")
WsSelectionCondition_FormSet2.set_field("ADD_SELECTION","0")
WsSelectionCondition_FormSet2.set_field("NEW_SELECTION","1")
WsSelectionCondition_FormSet2.set_field("EQ","0")
WsSelectionCondition_FormSet2.set_field("REVERSE","0")
WsSelectionCondition_FormSet2.set_field("OR","1")
WsSelectionCondition_FormSet2.set_field("AND","0")

for i in range(4,221):
	print(i)
	DataGrid1.set_row(0, ["Tunnel_Strings","JOIN","0",str(i),"1"])
	DataGrid1.set_row(1, ["Tunnel_Strings","JOIN","0",str(i+1),"1"])
	WsSelectionCondition_FormSet2.set_field("GRID",DataGrid1.serialise())
	WsSelectionCondition_FormSet2.run()
        #Call auto build on selected string
	MMpy.Command("#40221").run()