>: CG Forums on 3dtotal - The best forums for CG artists :.
threedy forums home
 


top-table-gradient
Go Back   3DTotal Forums > Help, Advice and Chat > Modelling, Lighting & Rendering Help
bottom-table-gradient

Reply
 
Thread Tools Display Modes
Old 13-07-2007, 03:14 PM   #1
Nukie
Registered User
 
Join Date: Aug 2005
Location: Netherlands
Posts: 1,638
Thanks: 5
Thanked 23 Times in 22 Posts
Awards Showcase
Threedy Top Poster - Silver: Contributing to the forums with 1,000+ posts - Issue reason: Target reached! Threedy Top Poster - Bronze: Contributing to the forums with 100+ posts - Issue reason: Target reached! 
Total Awards: 2
[MAXScript] Unable to Convert

Hi,

I have started learning MAXScript, and for that I'm following the tutorials that come with max. At this point I'm following the "How To" tutorials, and so far i'm at tutorial 5 "Selecting Non-Quad Polygons".

The tutorial itself is clear and it also works, but I thought "Lets try some things for myself" so instead of making a MacroScript I'm trying to create a rollout with 2 buttons: One for selecting the Non-Quads and one for deselecting them. Now this isnt so much of a problem and the rollout works, but the button (so far I'm still trying to get the "Select All" button to work) doesnt.

When I select my model (for testing I'm using a simple GeoSphere converted to Edit Poly) the script gives me the following error:

-- Unable to convert: true to type: Integer

The error highlights this line from the code:

polyop.setfaceselection base_obj face_selection

And here is the complete code:

Code:
rollout SelectNonQuads "Select all Non-Quad Polygons"
(
	label lab "Select all Non-Quad Polygons"
	button select "Select All" pos:[10,30]
	button deselect "Deselect All" pos:[80,30]
	
	on select pressed do
	(
		local face_selection = #()
		local base_obj = $.baseobject
		local num_faces = polyop.getnumfaces base_obj
		
		for f = 1 to num_faces do
		(
			local num_face_verts = polyop.getfacedeg base_obj f
			if num_face_verts != 4 do face_selection[f] = true
		)
		
		polyop.setfaceselection base_obj face_selection
		max modify mode
		modpanel.setcurrentobject base_obj
		subobjectlevel = 4
	)
)

createdialog SelectNonQuads width:160 height:60
Maybe worth to mention I'm not a die-hard programmer

Last edited by Mr. Bluesummers-3DT; 16-07-2007 at 08:18 PM.. Reason: Use [ code ] tags. ;)
Nukie is offline   Reply With Quote
Old 16-07-2007, 07:58 PM   #2
Nukie
Registered User
 
Join Date: Aug 2005
Location: Netherlands
Posts: 1,638
Thanks: 5
Thanked 23 Times in 22 Posts
Awards Showcase
Threedy Top Poster - Silver: Contributing to the forums with 1,000+ posts - Issue reason: Target reached! Threedy Top Poster - Bronze: Contributing to the forums with 100+ posts - Issue reason: Target reached! 
Total Awards: 2
230 pageviews and noone knows whats wrong?
Nukie is offline   Reply With Quote
Old 16-07-2007, 08:20 PM   #3
Mr. Bluesummers-3DT
Supplies Coordinator
 
Mr. Bluesummers-3DT's Avatar
 
Join Date: Oct 2004
Location: United States
Posts: 3,343
Thanks: 0
Thanked 11 Times in 8 Posts
Awards Showcase
Threedy Top Poster - Gold: Contributing to the forums with 2,000+ posts - Issue reason: Target reached! Threedy Top Poster - Silver: Contributing to the forums with 1,000+ posts - Issue reason: Target reached! Threedy Top Poster - Bronze: Contributing to the forums with 100+ posts - Issue reason: Target reached! The Golden Eye: Producing art worthy of being linked from the frontpage of either forums or 3DTotal.com - Issue reason: The particles tutorial got plugged along the top bar. Thumbs up!:  - Issue reason: For doing a great job in helping out! Low Poly Game Art - Gold: Winner of a low poly challenge! - Issue reason: For Excellence at Low Poly Art - Well Done! Low Poly Game Art - Gold: Winner of a low poly challenge! - Issue reason: For Excellence at Low Poly Art - Well Done! Speed Modelling - Gold: Winner of a speed modelling challenge! - Issue reason: Winner of a speed modelling challenge! 
Total Awards: 8
Quick Reply
Hmm...I think its because part of your code is trying to access an integer to select faces, but it's not getting the right type of data.

Code:
if num_face_verts != 4 do face_selection[f] = true
I bet that's the offending line. It's setting a {true,false,true,false} bit array when the polyOp method is expecting a {1,2,3,...n} list of faces to select. I'm at work so I can't fix the code for you, but that's probably where the problem is!

P.S. Try to "append" the array with face f rather than setting a bit at f. Your new line should resemble
Code:
if num_face_verts != 4 do face_selection = append face_selection f
__________________
Be sure to check out my blog because there's tons of useful resources there:

Last edited by Mr. Bluesummers-3DT; 16-07-2007 at 08:35 PM..
Mr. Bluesummers-3DT is offline   Reply With Quote
Old 17-07-2007, 02:34 AM   #4
Mr. Bluesummers-3DT
Supplies Coordinator
 
Mr. Bluesummers-3DT's Avatar
 
Join Date: Oct 2004
Location: United States
Posts: 3,343
Thanks: 0
Thanked 11 Times in 8 Posts
Awards Showcase
Threedy Top Poster - Gold: Contributing to the forums with 2,000+ posts - Issue reason: Target reached! Threedy Top Poster - Silver: Contributing to the forums with 1,000+ posts - Issue reason: Target reached! Threedy Top Poster - Bronze: Contributing to the forums with 100+ posts - Issue reason: Target reached! The Golden Eye: Producing art worthy of being linked from the frontpage of either forums or 3DTotal.com - Issue reason: The particles tutorial got plugged along the top bar. Thumbs up!:  - Issue reason: For doing a great job in helping out! Low Poly Game Art - Gold: Winner of a low poly challenge! - Issue reason: For Excellence at Low Poly Art - Well Done! Low Poly Game Art - Gold: Winner of a low poly challenge! - Issue reason: For Excellence at Low Poly Art - Well Done! Speed Modelling - Gold: Winner of a speed modelling challenge! - Issue reason: Winner of a speed modelling challenge! 
Total Awards: 8
P.S.
MaxScript isn't discussed in this community as much as it should. I'm sorry so much time has passed since you posted!
__________________
Be sure to check out my blog because there's tons of useful resources there:
Mr. Bluesummers-3DT is offline   Reply With Quote
Old 17-07-2007, 09:00 PM   #5
Nukie
Registered User
 
Join Date: Aug 2005
Location: Netherlands
Posts: 1,638
Thanks: 5
Thanked 23 Times in 22 Posts
Awards Showcase
Threedy Top Poster - Silver: Contributing to the forums with 1,000+ posts - Issue reason: Target reached! Threedy Top Poster - Bronze: Contributing to the forums with 100+ posts - Issue reason: Target reached! 
Total Awards: 2
Hey thanks man. No problem it took a while, I'm glad someone could help me. The code you gave me works perfectly.

Can you please explain me what the "append" part does? As I said I'm not a die hard programmer but I want to learn it.
Nukie is offline   Reply With Quote
Old 17-07-2007, 10:01 PM   #6
Mr. Bluesummers-3DT
Supplies Coordinator
 
Mr. Bluesummers-3DT's Avatar
 
Join Date: Oct 2004
Location: United States
Posts: 3,343
Thanks: 0
Thanked 11 Times in 8 Posts
Awards Showcase
Threedy Top Poster - Gold: Contributing to the forums with 2,000+ posts - Issue reason: Target reached! Threedy Top Poster - Silver: Contributing to the forums with 1,000+ posts - Issue reason: Target reached! Threedy Top Poster - Bronze: Contributing to the forums with 100+ posts - Issue reason: Target reached! The Golden Eye: Producing art worthy of being linked from the frontpage of either forums or 3DTotal.com - Issue reason: The particles tutorial got plugged along the top bar. Thumbs up!:  - Issue reason: For doing a great job in helping out! Low Poly Game Art - Gold: Winner of a low poly challenge! - Issue reason: For Excellence at Low Poly Art - Well Done! Low Poly Game Art - Gold: Winner of a low poly challenge! - Issue reason: For Excellence at Low Poly Art - Well Done! Speed Modelling - Gold: Winner of a speed modelling challenge! - Issue reason: Winner of a speed modelling challenge! 
Total Awards: 8
Quick Reply
No worries. The help file says:
Code:
append <array> <value>
Append value to array, growing it as necessary. Returns the resulting array.
It takes the array you passed it, slams the <value> parameter onto the end, and returns the resulting array. Below are some lines about how that works:
Code:
--Let's have an array
thisArray = #("cherry", "grape", "lime")

--Let's append another flavor!
append thisArray "orange"

--Wo oh, append doesn't alter the array, it returns the result.  We didn't catch it!
format "This array contains: %\n" thisArray

--Here's how we can catch the operation's result into the same array...
thisArray = append thisArray "orange"

--Just to double check.
format "This array contains: %\n" thisArray
The important thing to note here is that it doesn't modify the array directly; it returns the appended array. You have to assign it back into a variable, or it won't count. Not all array operations work like this, so it's important to keep the documentation handy when you're coding.

Happy scripting!
__________________
Be sure to check out my blog because there's tons of useful resources there:
Mr. Bluesummers-3DT is offline   Reply With Quote
Old 17-07-2007, 10:05 PM   #7
Mr. Bluesummers-3DT
Supplies Coordinator
 
Mr. Bluesummers-3DT's Avatar
 
Join Date: Oct 2004
Location: United States
Posts: 3,343
Thanks: 0
Thanked 11 Times in 8 Posts
Awards Showcase
Threedy Top Poster - Gold: Contributing to the forums with 2,000+ posts - Issue reason: Target reached! Threedy Top Poster - Silver: Contributing to the forums with 1,000+ posts - Issue reason: Target reached! Threedy Top Poster - Bronze: Contributing to the forums with 100+ posts - Issue reason: Target reached! The Golden Eye: Producing art worthy of being linked from the frontpage of either forums or 3DTotal.com - Issue reason: The particles tutorial got plugged along the top bar. Thumbs up!:  - Issue reason: For doing a great job in helping out! Low Poly Game Art - Gold: Winner of a low poly challenge! - Issue reason: For Excellence at Low Poly Art - Well Done! Low Poly Game Art - Gold: Winner of a low poly challenge! - Issue reason: For Excellence at Low Poly Art - Well Done! Speed Modelling - Gold: Winner of a speed modelling challenge! - Issue reason: Winner of a speed modelling challenge! 
Total Awards: 8
P.S.
Well, color me confused! It's not supposed to work like that, but I tested out that code block in Max8 and it appended the array without having to reassign. Wierd!

I guess you can go ahead and use
Code:
append thisArray "orange"
and count on it appending the array properly. *Shrug*
__________________
Be sure to check out my blog because there's tons of useful resources there:
Mr. Bluesummers-3DT is offline   Reply With Quote
Old 18-07-2007, 12:52 AM   #8
Nukie
Registered User
 
Join Date: Aug 2005
Location: Netherlands
Posts: 1,638
Thanks: 5
Thanked 23 Times in 22 Posts
Awards Showcase
Threedy Top Poster - Silver: Contributing to the forums with 1,000+ posts - Issue reason: Target reached! Threedy Top Poster - Bronze: Contributing to the forums with 100+ posts - Issue reason: Target reached! 
Total Awards: 2
Thanks for clearing it up...
Nukie is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 07:06 AM.


Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
all images displayed on this site are copyright the original artists and may not be reproduced, copied or published elsewhere without their express permission