|
|||||
|
|
#1 |
|
Registered User
Join Date: Aug 2005
Location: Netherlands
Posts: 1,638
Thanks: 5
Thanked 23 Times in 22 Posts
|
[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 ![]() Last edited by Mr. Bluesummers-3DT; 16-07-2007 at 08:18 PM.. Reason: Use [ code ] tags. ;) |
|
|
|
|
|
#2 |
|
Registered User
Join Date: Aug 2005
Location: Netherlands
Posts: 1,638
Thanks: 5
Thanked 23 Times in 22 Posts
|
230 pageviews and noone knows whats wrong?
![]() |
|
|
|
|
|
#3 |
|
Supplies Coordinator
Join Date: Oct 2004
Location: United States
Posts: 3,343
Thanks: 0
Thanked 11 Times in 8 Posts
|
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 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.. |
|
|
|
|
|
#4 |
|
Supplies Coordinator
Join Date: Oct 2004
Location: United States
Posts: 3,343
Thanks: 0
Thanked 11 Times in 8 Posts
|
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: |
|
|
|
|
|
#5 |
|
Registered User
Join Date: Aug 2005
Location: Netherlands
Posts: 1,638
Thanks: 5
Thanked 23 Times in 22 Posts
|
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. |
|
|
|
|
|
#6 |
|
Supplies Coordinator
Join Date: Oct 2004
Location: United States
Posts: 3,343
Thanks: 0
Thanked 11 Times in 8 Posts
|
Quick Reply
No worries. The help file says: Code:
append <array> <value> Append value to array, growing it as necessary. Returns the resulting array. 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
![]() Happy scripting!
__________________
Be sure to check out my blog because there's tons of useful resources there: |
|
|
|
|
|
#7 |
|
Supplies Coordinator
Join Date: Oct 2004
Location: United States
Posts: 3,343
Thanks: 0
Thanked 11 Times in 8 Posts
|
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"
__________________
Be sure to check out my blog because there's tons of useful resources there: |
|
|
|
|
|
#8 |
|
Registered User
Join Date: Aug 2005
Location: Netherlands
Posts: 1,638
Thanks: 5
Thanked 23 Times in 22 Posts
|
Thanks for clearing it up...
|
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|