ScriptSpot

Forum topic · Scripts Wanted

in-viewport status display

By darwin · 2018-08-26

Description

I would like to know if it is possible to see in the viewport what sub-object in mesh objects is selected or active

"I'm not a programmer and I don't have any scripting skills.
Please help me to make it works.

Moving on to the topic you can display more information in the viewport

fn CoordStatistics =
(
try (MaterialName = getRefCoordSys() ) catch(MaterialName = "")
gw.wText [10,40,0] MaterialName color:green
gw.updateScreen()
forceCompleteRedraw()
)
unRegisterRedrawViewsCallback CoordStatistics
registerRedrawViewsCallback CoordStatistics
CoordStatistics ()

-------------------------------------------------------------------------------------------

fn TransformationsStatistics =
(
try (MaterialName = toolMode.commandmode) catch(MaterialName = "")
gw.wText [10,55,0] MaterialName color:green
gw.updateScreen()
forceCompleteRedraw()
)
unRegisterRedrawViewsCallback TransformationsStatistics
registerRedrawViewsCallback TransformationsStatistics
TransformationsStatistics ()

-------------------------------------------------------------------------------------------

fn SubselectionStatistics =
(
try (MaterialName = $.GetEPolySelLevel()) catch(MaterialName = "")
gw.wText [10,70,0] MaterialName color:green
gw.updateScreen()
forceCompleteRedraw()
)
unRegisterRedrawViewsCallback SubselectionStatistics
registerRedrawViewsCallback SubselectionStatistics
SubselectionStatistics ()

-------------------------------------------------------------------------------------------

fn NameselectionStatistics =
(
try (MaterialName = objName = selection[1].name) catch(MaterialName = "")
gw.wText [10,85,0] MaterialName color:green
gw.updateScreen()
forceCompleteRedraw()
)
unRegisterRedrawViewsCallback NameselectionStatistics
registerRedrawViewsCallback NameselectionStatistics
NameselectionStatistics ()

-------------------------------------------------------------------------------------------

fn FPSStatistics =
(
frameNumber = ((slidertime as string) as integer)
try (MaterialName = "Frame: " + frameNumber as string) catch(MaterialName = "")
gw.wText [10,100,0] MaterialName color:green
gw.updateScreen()
forceCompleteRedraw()
)
unRegisterRedrawViewsCallback FPSStatistics
registerRedrawViewsCallback FPSStatistics
FPSStatistics ()

-------------------------------------------------------------------------------------------

Comments (6)

here the solution thanks to the help of jahman

darwin · 2018-09-02

fn meshStatistics =
if(classof (modPanel.getCurrentObject()) == Editable_Mesh) Then
(
SOLevelName = case SubObjectLevel of
(
0: #Object
1: #Vertex
2: #Edge
3: #face
4: #Polygon
5: #Element
)
try (SOLevelName = SubObjectLevel() ) catch(MaterialName = "")
gw.wText [10,100,0] SOLevelName color:green
gw.updateScreen()
forceCompleteRedraw()
)
unRegisterRedrawViewsCallback meshStatistics
registerRedrawViewsCallback meshStatistics
meshStatistics ()

.

jahman · 2018-08-31

you can access current Sub-Object level with a max global variable SubObjectLevel

darwin · 2018-08-31

It's correct what you say, but I can't make it work so that it shows the info on the screen, if it's achieved with editable poly like this

fn SubselectionStatistics =
(
try (MaterialName = $.GetEPolySelLevel()) catch(MaterialName = "")
gw.wText [10,70,0] MaterialName color:green
gw.updateScreen()
forceCompleteRedraw()
)
unRegisterRedrawViewsCallback SubselectionStatistics
registerRedrawViewsCallback SubselectionStatistics
SubselectionStatistics ()

.

jahman · 2018-08-31

you can use case of statement


SOLevelName = case SubObjectLevel of
(
    0: #Object
    1: #Vert
    2: #Edge
    3: ... and so on
)

Check mxs reference for modPanel.getCurrentObject() if you need to know what type of modifier you're working with since the above list of SOLevel names is only suitable for EditableMesh/Editablepoly and editpoly/editmesh modifiers.

close to solving it thanks to you.

darwin · 2018-08-31

Thank you very much for your help in solving this problem.

darwin · 2018-09-02

here the solution thanks to the help of jahman

fn meshStatistics =
if(classof (modPanel.getCurrentObject()) == Editable_Mesh) Then
(
SOLevelName = case SubObjectLevel of
(
0: #Object
1: #Vertex
2: #Edge
3: #face
4: #Polygon
5: #Element
)
try (SOLevelName = SubObjectLevel() ) catch(MaterialName = "")
gw.wText [10,100,0] SOLevelName color:green
gw.updateScreen()
forceCompleteRedraw()
)
unRegisterRedrawViewsCallback meshStatistics
registerRedrawViewsCallback meshStatistics
meshStatistics ()