PDA

View Full Version : SDK and max script - tough question


ice799
09-17-2006, 11:25 PM
Hey guys -

Quick background: I'm a unix systems programmer (lots of C and x86 assembly knowledge), but this is my first time working with 3DSMax SDK and max scrippting.

The problem: A max script has been created which assigns a custom attribute to an object in the scene. This is done more or less by doing the following:

on assign pressed do
(
for i in selection do
(
custAttributes.add i classCAs
i.class = classMaster.tv.selectedItem.text
)
)

For reference:
classCAs = attributes classAttributes
(
parameters classParams rollout:classMaster2
(
mass type:#float ui:massSpinner
price type:#float ui:priceSpinner
class type:#string
)
)

Now, I have written a C++ Plugin which exports each object in a file format which another program can use. In the export process, I ask 3d Studio max how many custom attributes an INode has, and it returns 0:

/* error check is ommited to save space... */
ICustAttribContainer *tmp = node->GetCustAttribContainer();
int numAttribs = tmp->GetNumCustAttribs();

Using a debugger, the function GetNumCustAttribs() returns 0, when I was hoping that the above max script code would add in custom attributes, class price and mass.

Is there something obvious I am missing here? I can provide more code if it would be useful for solving the problem -- I've only provided the lines which seem relevant to save space on this already lenghty post.

Thanks for the help and suggestions.

ice799
09-18-2006, 01:36 AM
So as it turns out, I added the custom attribs manually via 3ds max and tested the plugin and it worked.

This means there is a bug in the maxscript code I pasted above.

Anyone know what the problem is? I'm not sure what I'm doing wrong here...

Thanks.

DennisRoche
09-18-2006, 12:32 PM
hey hey

check your maxscript again - you need to make the selection an array first. i quickly did a test as i didn't know how to add custom attibutes to an object either.


customAttributes = attributes objectData
(
parameters main rollout:paramsRollout
(
hitPoints type:#float ui:spn_hits default:10
cost type:#float ui:spn_cost default:100
)

rollout paramsRollout "Custom"
(
spinner spn_hits "Hit Points:" range:[0,100,10] type:#float
spinner spn_cost "Cost:" range:[0,100,10] type:#float
)
)

rollout fooRollout "Test"
(
-- create
button btn_AddAttribute "Add attributes to selected" align:#center

-- events
on btn_AddAttribute pressed do (

selection = getCurrentSelection()
count = selection.count

for p = 1 to count do
(
-- add custom attributes
custAttributes.add selection[p] customAttributes
)

)
)

if theWindow != undefined then (
CloseRolloutFloater theWindow;
)
theWindow = newRolloutFloater "Foobar" 200 300
addRollout fooRollout theWindow


or you may not had the class attibutes defined correctly


customAttributes = attributes objectData
(
parameters main rollout:paramsRollout
(
hitPoints type:#float ui:spn_hits default:10
cost type:#float ui:spn_cost default:100
)

rollout paramsRollout "Custom"
(
spinner spn_hits "Hit Points:" range:[0,100,10] type:#float
spinner spn_cost "Cost:" range:[0,100,10] type:#float
)
)

CGTalk Moderation
09-18-2006, 12:32 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.