Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Scripting Boolean3 - how to use operands material ids when scripted?

Scripting Boolean3 - how to use operands material ids when scripted?

Anonymous
Not applicable
1,766 Views
6 Replies
Message 1 of 7

Scripting Boolean3 - how to use operands material ids when scripted?

Anonymous
Not applicable

Hello, I have been working on some scripted function for Boolean 3, but I don't seem able to get it to take the material id's of the operand into the Bool the same way as it does through the main UI. 
Currently I have...

BoolObject.materialOption = 0
BoolObject.AppendOperand BoolObject (Objs[a]) false
BoolOpNum = BoolObject.GetNumOperands()
BoolObject.SetOperationType BoolOpNum #subtraction


But the material ids on the output bool do not match that of the input, they do if I just use the picker in the UI. 

Am I using these commands in the wrong way? 

I would really appreciate your help, thanks!  😄

0 Likes
Accepted solutions (2)
1,767 Views
6 Replies
Replies (6)
Message 2 of 7

Swordslayer
Advisor
Advisor
Message 3 of 7

Anonymous
Not applicable

Ah, that is a real shame. 
I had feared that would be the case. 😕 

Thank you for letting me know - can you think of any work around to this issue in the meantime? - I'm pretty stumped and guessing we wont see an official fix for this in the foreseeable future... 

Thanks again, 

Graeme

0 Likes
Message 4 of 7

Anonymous
Not applicable

I also wonder, do you know if proboolean has the same issue?  - I probably don't need to be using boolean 3. 

0 Likes
Message 5 of 7

Swordslayer
Advisor
Advisor
Accepted solution

No, I don't think it has this exact issue but it has others, for example it doesn't work well with undo, for setting Reference/Move modes you have to make it active in commandpanel and send clicks to the UI (and it's not guaranteed to work either), same with cookie cutter options, and the list goes on... If you only need something simple, it might be a solution for you at the moment, though.

Message 6 of 7

Anonymous
Not applicable

Thanks for all of your help, I think I may need to move it over to proboolean tonight then (and just hope that those issue you mentioned don't cause too many extra problems) - Its too important of a feature to ignore really - But fingers crossed that it actually gets fixed in a future release for Boolean 3, as I do really like the new toolset. 

0 Likes
Message 7 of 7

Anonymous
Not applicable
Accepted solution

Follow Up:
I just wanted to come back with a follow up to the above comments , in case anybody else ends up here and wants to consider using ProBoolean as an alternative - Don't waste your time! 

I was test porting my scripts over to ProBoolean today, and it is just awful and clearly not supported from a scripting point of view. 

I used denisT's code on the links that Swordslayer supplied as a starting point - really interesting, I learnt a lot at least - sadly the definitions seem to have changed since then, but after some fiddling I got a working version for max 2018. It may be of use to someone else and save them some time, so i'll dump that here.

But yeah, on top of that, there is a whole bunch of other missing features from the documentation, if they exist I have no idea how to find them. 

- Cant select an operand by number

- Cant extract an operand

- Cant delete an operand 

- Cant get the number of operands in the boolean

Some of these you could perhaps get around with a similar method as the 'Add Method' button click trick, but it is a lot of dodgy code and risk of things going wrong in the best case scenario, so just not worth the risk for me past here. 

I will just have to live with the missing feature on Boolean 3 and hope it gets sorted one day - Haha, It is very hard to have any faith in Autodesk after just implementing workarounds to bugs on ProBoolean that have been around for almost 10 years without being corrected though...

 

Thanks again to SwordSlayer for his help, and goodluck to anyone who finds themself here in the future with the same issues. 🙂

Main Code by denisT - sept '09 - https://forums.cgsociety.org/t/what-wrong-with-my-proboolean-maxscript/1359245

hwnd_keyword = "*Boolean*"

fn getBooleanHWND =
(
--  for c in (windows.getChildrenHWND #max) while hwnd == undefined where c[5] == hwnd_keyword do 	-- OLD CODE
	for c in (windows.getChildrenHWND #max) while hwnd == undefined where (matchPattern (c[5] as string) pattern: hwnd_keyword ignoreCase:true) do 	
 (
	hwnd = UIAccessor.GetParentWindow c[1]
 )
 hwnd
)


fn setAddMethod method hwnd: update:on =  
(
	 
 if hwnd == unsupplied do hwnd = getBooleanHWND()
 if hwnd != undefined do
 (
  name = case method of
  (
   0: "Reference"
   1: "Copy"
   2: "Move"  
   3: "Instance"
   default: "Copy"
  )
  if (bt = windows.getChildHWND hwnd name) != undefined do UIAccessor.PressButton bt[1]
  if update do select selection
  ok
 )
)

setAddMethod 3