ScriptSpot

Forum topic · General Scripting

How to select Edges relative to the selected Face

By alphakanal · 2021-12-08

Description

Hi!
I'm quite new to MaxSxript and i'd like to bevel two selected side-by-side faces and chamfer the edges of the new beveled faces.

The selected Faces for this action will be always side-by-side.

I've enabled the MacroRecorder while executing the bevel/chamfer on the edidable poly shown on the left side of the Screenshot , and the commands look like this:

 
$.modifiers[#Edit_Poly].SetOperation #Bevel
$.modifiers[#Edit_Poly].bevelType = 1
$.modifiers[#Edit_Poly].bevelHeight = 3.6
$.modifiers[#Edit_Poly].bevelOutline = -4
$.modifiers[#Edit_Poly].Commit ()
subobjectLevel = 2
$.modifiers[#Edit_Poly].Select #Edge #{8, 13}
$.modifiers[#Edit_Poly].Select #Edge #{12}
$.modifiers[#Edit_Poly].Select #Edge #{11}
$.modifiers[#Edit_Poly].Select #Edge #{10}
$.modifiers[#Edit_Poly].Select #Edge #{9}
$.modifiers[#Edit_Poly].SetOperation #ChamferEdge
$.modifiers[#Edit_Poly].edgeChamferType = 1
$.modifiers[#Edit_Poly].chamferEdgeAmount = 1.187
$.modifiers[#Edit_Poly].edgeChamferSegments = 2
$.modifiers[#Edit_Poly].edgeChamferTension = 0.5
$.modifiers[#Edit_Poly].chamferEdgeOpen = off
$.modifiers[#Edit_Poly].Commit ()

The problem is, that the Egde indices are hard-coded and the code won't work on other faces - see screenshot the poly on the right side.

So is there a way to make this Edge-Selection relative to the selected faces ?

Hope someone could help me out. Thanks in advance & sorry for my bad english :)

Attachments
Comments (5)

obaida · 2022-01-16

you can select all wanted edges at the same time !!


$.modifiers[#Edit_Poly].Select #Edge #{8..13} -- its BitArray and this means select edges from 8 to 13 .

Update

alphakanal · 2022-01-14

I've tried to convert the Face selection to a Border selection - seems it'll do the job!


$.modifiers[#Edit_Poly].SetOperation #Bevel
$.modifiers[#Edit_Poly].bevelType = 1
$.modifiers[#Edit_Poly].bevelHeight = 3.6
$.modifiers[#Edit_Poly].bevelOutline = -4
$.modifiers[#Edit_Poly].Commit ()

// new  ->
$.modifiers[#Edit_Poly].ConvertSelectionToBorder #Face #Edge

// old ->
subobjectLevel = 2
$.modifiers[#Edit_Poly].SetOperation #ChamferEdge
$.modifiers[#Edit_Poly].edgeChamferType = 1
$.modifiers[#Edit_Poly].chamferEdgeAmount = 1.187
$.modifiers[#Edit_Poly].edgeChamferSegments = 2
$.modifiers[#Edit_Poly].edgeChamferTension = 0.5
$.modifiers[#Edit_Poly].chamferEdgeOpen = off
$.modifiers[#Edit_Poly].Commit ()

Thank you so far!!

But i guess i'll be back soon, because the script isn't done yet ;-)

Update

alphakanal · 2022-01-14

I've tried to convert the Face selection to a Border selection - seems it'll do the job!


$.modifiers[#Edit_Poly].SetOperation #Bevel
$.modifiers[#Edit_Poly].bevelType = 1
$.modifiers[#Edit_Poly].bevelHeight = 3.6
$.modifiers[#Edit_Poly].bevelOutline = -4
$.modifiers[#Edit_Poly].Commit ()

// new  ->
$.modifiers[#Edit_Poly].ConvertSelectionToBorder #Face #Edge

// old ->
subobjectLevel = 2
$.modifiers[#Edit_Poly].SetOperation #ChamferEdge
$.modifiers[#Edit_Poly].edgeChamferType = 1
$.modifiers[#Edit_Poly].chamferEdgeAmount = 1.187
$.modifiers[#Edit_Poly].edgeChamferSegments = 2
$.modifiers[#Edit_Poly].edgeChamferTension = 0.5
$.modifiers[#Edit_Poly].chamferEdgeOpen = off
$.modifiers[#Edit_Poly].Commit ()

Thank you so far!!

But i guess i'll be back soon, because the script isn't done yet ;-)

Face to Edge on Edit_Poly

obaida · 2022-01-11


$.Edit_Poly.ConvertSelection #Face #Edge
subObjectLevel = 2
$.Edit_Poly.GetSelection #Edge --Extra Step (if you wat to Get Selected Edges as bitArray)

*You need to select the Edit Poly Modifier before running previous commands .

Ok, thanks for the answer - but there's still a problem

alphakanal · 2022-01-14

Ok, thanks for the answer! I've changed the script like this:


$.modifiers[#Edit_Poly].SetOperation #Bevel
$.modifiers[#Edit_Poly].bevelType = 1
$.modifiers[#Edit_Poly].bevelHeight = 3.6
$.modifiers[#Edit_Poly].bevelOutline = -4
$.modifiers[#Edit_Poly].Commit ()
subobjectLevel = 2
// this line is new ->
$.modifiers[#Edit_Poly].GetSelection #Edge 

// i have deleted these hard-coded id lines  ->
$.modifiers[#Edit_Poly].Select #Edge #{8, 13}
$.modifiers[#Edit_Poly].Select #Edge #{12}
$.modifiers[#Edit_Poly].Select #Edge #{11}
$.modifiers[#Edit_Poly].Select #Edge #{10}
$.modifiers[#Edit_Poly].Select #Edge #{9}



// old stuff ->
$.modifiers[#Edit_Poly].SetOperation #ChamferEdge
$.modifiers[#Edit_Poly].edgeChamferType = 1
$.modifiers[#Edit_Poly].chamferEdgeAmount = 1.187
$.modifiers[#Edit_Poly].edgeChamferSegments = 2
$.modifiers[#Edit_Poly].edgeChamferTension = 0.5
$.modifiers[#Edit_Poly].chamferEdgeOpen = off
$.modifiers[#Edit_Poly].Commit ()

Now is the problem that the ChamferEdge( old stuff ) isn't applied