How can I use a variable inside a modifier line?

How can I use a variable inside a modifier line?

m.ayed002
Contributor Contributor
1,022 Views
3 Replies
Message 1 of 4

How can I use a variable inside a modifier line?

m.ayed002
Contributor
Contributor

Hello,

 

I'm a complete newbie in this, I don't have have much programing knowledge just the basics and I'm just playing around trying to learn it and make buttons to help me save time doing some tasks that I find myself doing repetedly

 

I want to select the faces  (in edit poly) of the sides of a box no matter how many faces it have

so if a box is [n,m,L] I want to select {n*m*2+1 .. n*L*2+m*L*2}  <- lets call this w 

I have been able to assign the variables n m and L using $.heightsegs $.widthsegs and $.lengthsegs 

But I can't use them inside the modifer like this ( $.modifiers[#Edit_Poly].Select #Face #{w} )

 

It would be a huge help if anyone can help me with this, I attached my file just in case

 

Thanks 🙂 

 

 

 

0 Likes
Accepted solutions (1)
1,023 Views
3 Replies
Replies (3)
Message 2 of 4

Swordslayer
Advisor
Advisor
Accepted solution

 

 

if isKindOf $ Node and isKindOf $.baseobject Box and isValidObj $.modifiers[Edit_Poly] do
(
	local n = $.baseobject.widthsegs
	local m = $.baseobject.lengthsegs
	local L = $.baseobject.heightsegs

	local w = #{n * m * 2 + 1 .. n * m * 2 + n * L * 2 + m * L * 2}
	w.count = $.modifiers[Edit_Poly].GetNumFaces() -- SetSelection only works if the bitarray lenght matches the total number of verts/edges/faces
	$.modifiers[Edit_Poly].SetSelection #Face w
)

 

 

Message 3 of 4

m.ayed002
Contributor
Contributor
Thanks alot! It makes sense!

if isKindOf $ Node and isKindOf $.baseobject Box and isValidObj $.modifiers[Edit_Poly] do : What does this sentence mean in normal language?
I tried looking up those in the documentation of maxscript but is too general and not very easy to work with

I'll go try this now 😄
0 Likes
Message 4 of 4

m.ayed002
Contributor
Contributor

It worked for me with just this 🙂 

 

 

	on Dont_Touch_Before_setting_up_a_box changed val do
	(
		local n = $.baseobject.widthsegs
	local m = $.baseobject.lengthsegs
	local L = $.baseobject.heightsegs
		local w = #{n * m * 2 + 1 .. n * m * 2 + n * L * 2 + m * L * 2}
			
		modPanel.addModToSelection (Edit_Poly ()) ui:on
			subobjectLevel = 4
		$Box.modifiers[#Edit_Poly].Select #Face w
		$Box.modifiers[#Edit_Poly].SetOperation #Inset
		$Box.modifiers[#Edit_Poly].insetType = 1
		$Box.modifiers[#Edit_Poly].insetAmount = 0.15
		$Box.modifiers[#Edit_Poly].Commit ()
	
		
	)

 

Now I will try to the inset amount a changeable variable and add more options (texturing and other operations)

I'm trying to make a low poly building generator in case anyone is wondering, for now I'm trying the easiest which is a simple glass skyscraper

 

0 Likes