Notifications
Clear all

[Closed] How to find inner contour of an object?

Any advices of how to draw the yellowish and greenish splines?
The main objects is built with rectangles only(not attached).

48 Replies

Did you try shape booleans introduced in newer max versions?
If shape boolean isn’t an option you could start with something like this

delete objects
delete helpers
gc()
Rectangle length:1300 width:100 cornerRadius:0 pos:[-750,-50,0] wirecolor:white
Rectangle length:100 width:1700 cornerRadius:0 pos:[150,550,0] wirecolor:white
Rectangle length:1600 width:100 cornerRadius:0 pos:[950,-300,0] wirecolor:white
Rectangle length:100 width:1200 cornerRadius:0 pos:[-100,-650,0] wirecolor:white
Rectangle length:800 width:200 cornerRadius:0 pos:[400,-200,0] wirecolor:white
Rectangle length:100 width:700 cornerRadius:0 pos:[-50,150,0] wirecolor:white
Rectangle length:500 width:100 cornerRadius:0 pos:[-150,-150,0] wirecolor:white
Rectangle length:100 width:300 cornerRadius:0 pos:[650,-250,0] wirecolor:white
Rectangle length:100 width:1200 cornerRadius:0 pos:[300,-950,0] wirecolor:white
Rectangle length:600 width:200 cornerRadius:0 pos:[-700,-1000,0] wirecolor:white
Rectangle length:100 width:1800 cornerRadius:0 pos:[300,-1250,0] wirecolor:white
Rectangle length:1000 width:100 cornerRadius:0 pos:[1150,-700,0] wirecolor:white
Rectangle length:100 width:600 cornerRadius:0 pos:[1300,-150,0] wirecolor:white

redrawViews()
sleep 1.0
bounds = shapes.max - shapes.min
tri = plane widthsegments:1 lengthsegments:1 width:bounds.x length:bounds.y pos:shapes.center wirecolor:yellow
convertToMesh tri

redrawViews()
sleep 1.0

for s in shapes do
(
	x = copy s pos:(s.pos - z_axis)	
	addModifier x (Extrude amount:10)
	tri -= x -- mesh boolean
	delete x
	redrawViews()
	sleep 0.15
)

update tri
select tri
Gif

Thank you.
With simple objects works with no problems. With complex objects 3dsMax is crashing.

I’ve tried with shapeBoolean, I think there is a post from you somewhere on the forum, but… if the proper rectangles are not selected the result is wrong.

1 Reply
(@serejah)
Joined: 10 months ago

Posts: 0

Yeah, actually brand new compound shape union fails exactly as the old shape boolean in the simplest case.
Perhaps the only way to go is to refine segments, collapse to mesh, weld and extract borders.
Check out this thread

http://www.angusj.com/delphi/clipper.php
I use it to get the outline like the selection line , also to

I have a version which combines all rectangles -> collapse to mesh -> weled and exctract borders, but it needs the proper rectangles to be selected manually. What I am trying to do is to find a way to tell the scirpt:
“those are all the rectangles, find the inner outline”, with no success so far. My next ideas:

  • create a grid of points all over the rectangles area
  • remove all points inside the rectangles
  • use the rest of the points, which should be placed inside the “inner” area to find the outline
    Most probably this will take too much time.
  • start from a point, manually placed inside the “inner” area
  • find the closest segment
  • use this segment to find the next one, it may be on the same rectangle or on another rectangle
  • loop until the first closest point is reached again
    Most probably this will take much time than my first idea, because here I have to calculate segments intersections, where the intersection point is located, etc.

I know about it. Did you managed to use it inside 3ds Max with mesh/spline objects?

my usage

Thank you.
If you want to share the secret, feel free to do it.

post, posted after 8 attempts.

if you want pure mxs solution look at this one as well. Not really fast even with simple cases and also splines must intersect in order it to produce correct resulting polygon
http://www.scriptspot.com/3ds-max/scripts/zoa-spline-2-poly

Gif

32qPLbaVQw

1 Reply
(@miauu)
Joined: 10 months ago

Posts: 0

I have a maxscript solution, but it requires proper rectangles to be selected.

Here is a video: https://drive.google.com/file/d/12bZ3gS-1kiHz5H3NeBvzwMkHn8QNOE39/view?usp=sharing

@AEI Do you have any idea why could it be so imprecise at low point count?

Gif

vtvLVI5ORU

I just wrote a very rudimentary algorithm that extracts the inner shapes or outer shape without the need of converting to mesh or attaching the shapes.

It seems to work with a test model I build based on your draws, but I don’t know if it would work with any scene you may have.

What I don’t understand is what you mean when you say:

I also have to somehow tell the algorithm which are the rectangles, otherwise where is it supposed to look for?

4 Replies
(@miauu)
Joined: 10 months ago

Posts: 0

Here is a test scene, saved for max2014: https://drive.google.com/file/d/1QDPwTibENai9_66Rj_gmng_Nv-ovyc5n/view?usp=sharing

With yellow what my code produce:

If I pass all shapes from several layers, among the passed shapes there will be shapes which the script should not take into account. For example, in the image above all single rectangles at the bottom must not be processed by the script. When I manually select the shapes I need, those rectangles will not be in my selection and the script will include them in its calculations. But, when everything is automated those rectangles will be sent to the script and it have to exclude them from the calculations.

Thank you. I will test it with my scene.

(@miauu)
Joined: 10 months ago

Posts: 0

Thank you for the code. Here what I have with it:

It always misses some rectangles.

Can you use the scene below and to show the results?

Test scene(max2014): https://drive.google.com/file/d/1_S3uxe4ROYXCfqJFKVxUomk7kC_eVAn9/view?usp=sharing

(@polytools3d)
Joined: 10 months ago

Posts: 0

I got a step closer (passing all the shapes), but there are some remaining objects that should not be included.

(@miauu)
Joined: 10 months ago

Posts: 0

Please, see this image:

This is how my code works depending of the splines I pass to it.

Page 1 / 4