Notifications
Clear all

[Closed] Get Open Edges Count from Body Object

Hi there,

I’m working on a script importing lots of CAD files to max body objects. (works fine)

While importing in batch mode i’m also taking screengrabs to save it next to the resulting max file.
For easier judgement of the quality of the cad files i overlay some statistics before taking a screengrab like vertcount, object count etc.

Now what im trying is to get the value that is displayed is the command panel when you select a body object, namely the $$$ Open E. (See Screenshot)

This open edges count helps a lot when judging cad files.

I couldn’t find a way to get this value as a property of the object, so i tried the UIAccessor way.

This is the way to get there:

setCommandPanelTaskMode #modify
commandpanel = (windows.getchildhwnd #max "Command Panel")
BodyRollout = (windows.getchildhwnd commandpanel[1] "Editable Body Object") --- get the rollout
myControls = UIAccessor.GetChildWindows BodyRollout[2] --- all controls in the rollout
myValueString = (UIAccessor.GetWindowText myControls[11]) --- the label holding the value


The obvious problems with this solution are:

  1. imho not a good way to do it. It would be much better to just get a simple property

  2. if there are more than one object, i have to loop through them and select each solo

3. While looping over the objects the command panel doesn’t update properly, so it’s not collecting all my values.
Not true, got that fixed, i did the counting wrong.

  1. it’s slow.

Now, do you guys know of a way to get this open edges count without the UIAccessor?

Or if not, how do i enforce a command panel refresh before reading the value? This does not apply anymore. It actually refreshes.

Cheers

8 Replies

look at OpenEdges.Check and meshop.getOpenEdges

both give you a list of open edges for a geometry object. go through all of them and count…

1 Reply
(@heilandzack)
Joined: 10 months ago

Posts: 0

Thank you for answering.

So i tried OpenEdges.Check, wich returns failed for body objects.
This works perfect for meshes and poly objects, but not for body objects:

theResults = #()
resultType = openEdges.Check currentTime $ &theResults
theResults as bitarray
myCount = theResults.count


This gives me correct results again for mesh and poly objects, but not for body objects:

myResults = (meshop.getOpenEdges $.mesh) as array
openedgecount = myResults.count


What’s bugging me is that the value is already there, visible in the UI. It just seems like there’s no way to access it with code.
Also, Open edges on a body object is something different afaik. If i access .mesh properties or snapshotasmesh i would be working with the viewport representation, but not the “real” body object, which would be more like Nurbs, but still different …

Body_Object is a different story. I don’t see any topology information exposed with the object … for max sdk it’s a black-box too.

so you are probably right and only way is to read “info” from UI

Okay, thank you.

Then at least i have some confirmation

You can hack it with this modified version of your code. I am sure Denis knows a better method, but it should work.

setCommandPanelTaskMode #modify
commandpanel = (windows.getchildhwnd #max "Command Panel")
BodyRollout = (windows.getchildrenhwnd commandpanel[1])
myValueArray = for val in BodyRollout where matchpattern val[5] pattern:"*Open*" collect val
myValueStrings = for val in myValueArray collect val[5]
if myValueStrings.count > 1 then myValueString = myValueStrings else myValueString = myValueStrings[1]
myValueString

-Eric

nothing to do with scripting coz I can’t script…but here’s my take…

  • select all your Body objects
  • Join Bodies (I guess this is Boolean for Body ?)
  • now select the new ‘Consolidated’ body object (to be safe, you’d prolly want Operation to be Do Nothing)
  • the ‘counts’ are now the totals…so you need to read just 1 label.

This is assuming you make your call on the ‘total’ per file

1 Reply
(@heilandzack)
Joined: 10 months ago

Posts: 0

I guess that would work, although i don’t want to combine them all to one.

Yepp, that’s exactly the reason why i want to know the open edges count. Being able to batch import a folder and then being able to see very fast if the data the client sends is usable is my goal. Open Edges is a very good indicator for that imho.

I prefer body objects instead of straight to mesh, because of the tesselation control you have before converting to mesh. That is quite useful if you know what you’re going for.

For now i’m going with the read-from-UI-hack although i’m not really happy with it.
Thanks guys!

Looks like I missed some of your notes from the top. The only last idea I can think of is avoid command panel and use the create panel. Loop through the body objects, and convert them to body objects (this should give you the same object), not sure if this a better method or not, but a thought.

You could do what vusta recommends, but be sure to create a JoinBodies and set it to do nothing. Also, save before hand certain things done with nPower technology is not undoable and has caused issues for me by creating a damaged object that can’t be recovered. Open Edges in Body Objects simply means they were not welded on import due to too low of a tolerance (not accessible to the user) or badly designed CAD, and sometimes both.

Personally I have given up on Body Objects. Concept is good, but performance is too low and unreliability for me has been too high. Unfortunately the technology is developed and managed by a 3rd party, not Autodesk, so any changes will have to come from nPower. Since AFAIK they haven’t exposed any of this in the plugins they sell, then don’t expect them to be in Body Objects, which are a version of BREPS that have had features removed from the UI, but the maxscript code is still there. Don’t try to use anything not exposed to the UI as it can be instant crash.

-Eric