PDA

View Full Version : windows and doors data collection with dropdownlist


marcello1
11-18-2011, 06:26 PM
I am trying to make a rollout that would allow me to output certain properties of windows or doors based on selection via dropdownlist with no success. See the script below where the dropdownlist and conditional statements if b == "windows" then and if b == "doors" then have been made a comment since I am not being able to make them work :sad: . I am also attaching a scene that I am using for testing the script.
I appreciate any comments. Thanks in advance.

--doors and windows data extraction with UI
rollout dwdeaRoll "Doors & Windows Data Extraction Assistant" width:200 height:100
(
--dropdownlist b "collect data from:" items:#("windows","doors")
button c "collect data"
--if b == "windows" then
on c pressed do
(
for o in geometry where hasproperty o "Horizontal_Frame_Width" do format "% % Width %\n" (classof o) o.name o.Width
for o in geometry where hasproperty o "Horizontal_Frame_Width" do format "% % Height %\n" (classof o) o.name o.Height
for o in geometry where hasproperty o "Horizontal_Frame_Width" do format "% % Depth %\n" (classof o) o.name o.Depth
for o in geometry where hasproperty o "Horizontal_Frame_Width" do format "% % Frame_Thickness %\n" (classof o) o.name o.Frame_Thickness
for o in geometry where hasproperty o "Horizontal_Frame_Width" do format "% % Glazing_Thickness %\n" (classof o) o.name o.Glazing_Thickness
for o in geometry where hasproperty o "Horizontal_Frame_Width" do format "% % Horizontal_Frame_Width %\n" (classof o) o.name o.Horizontal_Frame_Width

--if (b == "doors") then
for o in geometry where hasproperty o "Leaf_Thickness" do format "% % Width %\n" (classof o) o.name o.Width
for o in geometry where hasproperty o "Leaf_Thickness" do format "% % Height %\n" (classof o) o.name o.Height
for o in geometry where hasproperty o "Leaf_Thickness" do format "% % Depth %\n" (classof o) o.name o.Depth
for o in geometry where hasproperty o "Leaf_Thickness" do format "% % Frame_Width %\n" (classof o) o.name o.Frame_Width
for o in geometry where hasproperty o "Leaf_Thickness" do format "% % Frame_Depth %\n" (classof o) o.name o.Frame_Depth
)
)
createDialog dwdeaRoll

Pjanssen
11-18-2011, 07:52 PM
Please use the [ code ] and [ /code ] tags and indentation, that will make your code a lot easier to read.

You can use the dropdownlist's selected property.
if b.selected == "windows" then (
http://docs.autodesk.com/3DSMAX/14/ENU/MAXScript%20Help%202012/files/GUID-172DE6D6-796F-419B-936E-4FD64AD24CB-1783.htm

marcello1
11-18-2011, 08:18 PM
Thank you very much. I guess the next problem in the script is to combine properly the for loop with the conditional statement and the button event handler. I am having a hard time understanding which one goes first in the script and the proper syntax :sad:
I will keep trying and reading the reference material but if anybody has any hint I appreciate any comments.

sorry for not using the proper script format, I have been copying and pasting in notepad, I should probably use another work flow.

Pjanssen
11-18-2011, 08:27 PM
on c pressed do (
if b == "windows" then (
for o in geometry where hasProperty o "Horizontal_Frame_Width" do (
format "% % Width %\n" (classof o) o.name o.Width
[...]
)
)
else if b == "doors" then (
[...]
)
)

It might be better to use isKindOf or some other way of checking the object's class instead of "hasProperty".

marcello1
11-18-2011, 08:37 PM
yes! Thank you.
I got it somehow to work (see attachment) just before reading your post. I am not using else and it seems to work. The big problem I had was with parenthesis...

...And also the part where I am using specific properties of doors and windows (Horizontal_Frame_Width and Leaf_Thickness) to point to the right objects is probably not a great solution as I wish I could just call the category of objects windows and doors but I am not sure if possible and how to accomplish.

Thanks again Pjanssen for your valuable advice.

CGTalk Moderation
11-18-2011, 08:37 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.