CGTalk > Software > Autodesk 3ds max > 3dsMax SDK and MaxScript
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 01-17-2012, 11:18 PM   #1
Dmaxer
Lord of the posts
 
Dmaxer's Avatar
portfolio
Danny McAuliffe
3d modeler/ script writer
London, United Kingdom
 
Join Date: Aug 2003
Posts: 864
Send a message via MSN to Dmaxer
help with a part of this script please

I trying to write a script that make a old fashion smoke chimney , its all going well but the one thing I cant get it to do is offset every other row of bricks so each one is just sitting on top of the one below, anyway Ive posted the script below in the hope maybe someone can have a look at it and show me what I need to do.

thanks for reading



Code:
( if main_win1 != undefined do closerolloutfloater main_win1 main_win1 = newRolloutFloater "Chimney Maker" 205 450 rollout params "Chimney" ( Group "Make Chimney" ( button Adcen "Create Center" tooltip:"will make Chimney center" width: 75 offset:[0,-5] pickbutton objToRot "Pick Rotate About" width:120 autoDisplay:true message:"Pick a object to rotate about" button doit "Create Chimney" tooltip:"will make a Chimney" width: 85 -- Doit progressbar workin color:blue checkbox dob "Delete Old Blocks" width:87 height:28 checked:true ) Group "Chimney Size" ( Spinner x "Brick amount : " range:[1,100,40] type:#integer align:#right width:80 offset:[-1,0] Spinner y "Chimney diameter : " range:[5,1000,308] type:#integer align:#right width:95 offset:[-1,0] Spinner st "Chimney height : " range:[1,100,2] type:#integer align:#right width:80 offset:[-1,0] Spinner tap "Chimney tapper : " range:[0,10,10] type:#integer align:#right width:80 offset:[-1,0] ) Group "Brick Settings" ( Spinner f "Fillet size : " range:[0,100,0.1] align:#right width:80 offset:[-1,0] Spinner g "Fillet Segments : " range:[0,10,1] type:#integer align:#right width:55 offset:[-1,0] Spinner h "Brick Height : " range:[1,500,20] type:#integer align:#right width:80 offset:[-1,0] Spinner l "Brick Width : " range:[1,1000,46] type:#integer align:#right width:80 offset:[-1,0] Spinner w "Brick Length : " range:[1,1000,20] type:#integer align:#right width:80 offset:[-1,0] Spinner Brickseg "Brick Segments : " range:[1,10,4] type:#integer align:#right width:80 offset:[-1,0] ) on objToRot picked obj do ( if obj != undefined do ( objToRot.text = obj.name ) ) on Adcen pressed do ( -- make dummy box at 0,0,0 Dummy pos:[0,0,0] isSelected:on $.name = "Chimney_Center" ) on doit pressed do ( undo "Circle Array" on ( max create mode if dob.checked == true then ( try delete $Chimney_Brick* catch print"No bricks to Delete" ) wi = w.value li = l.value fi = f.value gi = g.value he = h.value seg = Brickseg.value count = y.value row = x.value stp = st.value zh = stp+he for ia = 1 to stp do ( -- main loop do this loop height times workin.value = 100.*ia/stp -- for progress bar theBox = ChamferBox pos:[count,0,he*ia ] Length_Segments:seg Width_Segments:seg Height_Segments:seg width:wi length:li height:he fillet:fi Fillet_Segments:gi theBox.name = (uniquename "Chimney_Brick") -- make a brick clearSelection() a = theBox --getNodeByName fisrt brick in the ring j = 360/wi -- brick amount c = row--objCount.value ro = getNodeByName objToRot.text -- object to rotate around ang = 360/c angb = ang - (wi/360) for i = 1 to (c - 1) do -- this loop copys the brick as it rotates it around the center object (ro) picked with the button ( about ro rotate a (ang) z_axis cp = copy a -- copy and rotate all but the last brick selectMore cp -- add to ring sellection ) about ro rotate a (ang) z_axis -- make last brick selectMore a -- add to ring sellection workin.value = 0) -- end of height loop ) -- end of undo array ) -- end of doit pressed ) -- end of rollout addRollout params main_win1 ) ----end
__________________
My Battersea power station project http://forums.cgsociety.org/showthr...p?f=43&t=666794

My Website
 
Old 01-18-2012, 01:55 AM   #2
Panayot
Frequenter
portfolio
Panayot Karabakalov
Technical Artist
Bulgaria
 
Join Date: Mar 2011
Posts: 212
well, i'll do this in another way... but after brief reading the code, i made some quick (and not tested) editing. i hope its hepls anyway
Code:
( if main_win1 != undefined do closerolloutfloater main_win1 main_win1 = newRolloutFloater "Chimney Maker" 205 450 rollout params "Chimney" ( Group "Make Chimney" ( button Adcen "Create Center" tooltip:"will make Chimney center" width: 75 offset:[0,-5] pickbutton objToRot "Pick Rotate About" width:120 autoDisplay:true message:"Pick a object to rotate about" button doit "Create Chimney" tooltip:"will make a Chimney" width: 85 enabled:off ----//EDITED: progressbar workin color:blue checkbox dob "Delete Old Blocks" width:87 height:28 checked:true ) Group "Chimney Size" ( Spinner x "Brick amount : " range:[1,100,40] type:#integer align:#right width:80 offset:[-1,0] Spinner y "Chimney diameter : " range:[5,1000,308] type:#integer align:#right width:95 offset:[-1,0] Spinner st "Chimney height : " range:[1,100,2] type:#integer align:#right width:80 offset:[-1,0] Spinner tap "Chimney tapper : " range:[0,10,10] type:#integer align:#right width:80 offset:[-1,0] ) Group "Brick Settings" ( Spinner f "Fillet size : " range:[0,100,0.1] align:#right width:80 offset:[-1,0] Spinner g "Fillet Segments : " range:[0,10,1] type:#integer align:#right width:55 offset:[-1,0] Spinner h "Brick Height : " range:[1,500,20] type:#integer align:#right width:80 offset:[-1,0] Spinner l "Brick Width : " range:[1,1000,46] type:#integer align:#right width:80 offset:[-1,0] Spinner w "Brick Length : " range:[1,1000,20] type:#integer align:#right width:80 offset:[-1,0] Spinner Brickseg "Brick Segments : " range:[1,10,4] type:#integer align:#right width:80 offset:[-1,0] ) --//EDITED: --on objToRot picked obj do (if obj != undefined do (objToRot.text = obj.name)) -- autoDisplay:true did this already on objToRot picked obj do (doit.enabled = isValidNode obj) on Adcen pressed do ( -- make dummy box at 0,0,0 Dummy pos:[0,0,0] name:"Chimney_Center" isSelected:on ) on doit pressed do ( undo "Circle Array" on ( max create mode if dob.checked do ( local old = $Chimney_Brick* as array if old.count > 0 do delete old ) wi = w.value li = l.value fi = f.value gi = g.value he = h.value seg = Brickseg.value count = y.value row = x.value stp = st.value zh = stp+he for ia = 1 to stp do ( -- main loop do this loop height times workin.value = 100.*ia/stp -- for progress bar theBox = ChamferBox pos:[count,0,he*ia ] Length_Segments:seg Width_Segments:seg \ Height_Segments:seg width:wi length:li height:he fillet:fi Fillet_Segments:gi \ name:(uniqueName "Chimney_Brick") -- make a brick clearSelection() a = theBox --getNodeByName fisrt brick in the ring j = 360/wi -- brick amount c = row --objCount.value ro = getNodeByName objToRot.text -- object to rotate around --//WHAT IF NO SUCH NODE? ang = 360/c angb = ang - (wi/360) for i = 1 to (c - 1) do -- this loop copys the brick as it rotates it around the center object (ro) picked with the button ( about ro rotate a (ang) z_axis cp = copy a -- copy and rotate all but the last brick selectMore cp -- add to ring sellection ) about ro rotate a (ang) z_axis -- make last brick selectMore a -- add to ring sellection --//EDITED: -------------------------- if mod ia 2 == 0 do about selection.center rotate selection (ang/2) z_axis -------------------------------------- workin.value = 0 ) -- end of height loop ) -- end of undo array ) -- end of doit pressed ) -- end of rollout addRollout params main_win1 ) ----end
__________________
* everyone can win previous war
 
Old 01-18-2012, 01:10 PM   #3
Dmaxer
Lord of the posts
 
Dmaxer's Avatar
portfolio
Danny McAuliffe
3d modeler/ script writer
London, United Kingdom
 
Join Date: Aug 2003
Posts: 864
Send a message via MSN to Dmaxer
Thanks Panayot I will try that when I get home tonight
__________________
My Battersea power station project http://forums.cgsociety.org/showthr...p?f=43&t=666794

My Website
 
Old 01-18-2012, 02:28 PM   #4
Dmaxer
Lord of the posts
 
Dmaxer's Avatar
portfolio
Danny McAuliffe
3d modeler/ script writer
London, United Kingdom
 
Join Date: Aug 2003
Posts: 864
Send a message via MSN to Dmaxer
the line you added gives me an error , I dont understand this part "if mod ia 2 ==0 "
could you tell me what the Mod command is for ?
thanks again for your help
-- Error occurred in anonymous codeblock; filename: C:\Users\Dmax\temp.ms; position: 3464; line: 84
-- Syntax error: at ., expected <factor>
-- In line: if mod ia 2 == 0 do about selection.c
__________________
My Battersea power station project http://forums.cgsociety.org/showthr...p?f=43&t=666794

My Website

Last edited by Dmaxer : 01-18-2012 at 02:51 PM.
 
Old 01-18-2012, 10:16 PM   #5
Panayot
Frequenter
portfolio
Panayot Karabakalov
Technical Artist
Bulgaria
 
Join Date: Mar 2011
Posts: 212
the script working at all, but now i test it and made 2 mini editings, so just replace/update this 2 lines:
Code:
--//OLD: ro = getNodeByName objToRot.text --//NEW: ro = objToRot.object --//OLD: if mod ia 2 == 0 do about selection.center rotate selection (ang/2) z_axis --//NEW: if mod ia 2 == 0 do about (selection.center) rotate selection (ang/2) z_axis

Mod() is a modulo arithmetic function that return remainder after 1st number was divided by 2nd number. And i use it here with devider 2 to get odd/even iteration (if the "mod ia 2" return 0 then its even, else odd).

One more tip... as you made a dummy always at origin [0,0,0] and then pick this object, but you can skip this 2 buttons and just use "about [0,0,0] rotate a (ang) z_axis".
Also you can create the ring-array just once and then clone it as 'group', move it up by Z and rotate it by the half of the angle.

__________________
* everyone can win previous war
 
Old 01-18-2012, 10:33 PM   #6
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,865
Send a message via ICQ to denisT
old fashion smoke chimney

it's definitely the task for a Scripted Geometry Plug-in... or a Scripted SimpleObject...

Last edited by denisT : 01-18-2012 at 10:58 PM.
 
Old 01-19-2012, 09:18 AM   #7
Dmaxer
Lord of the posts
 
Dmaxer's Avatar
portfolio
Danny McAuliffe
3d modeler/ script writer
London, United Kingdom
 
Join Date: Aug 2003
Posts: 864
Send a message via MSN to Dmaxer
Thanks Panayot that works fine , Im going to play around with it this weekend and see if I can make it a bit better , once again thanks for all your help.

denisT , Im sure your right mate maybe I will look into making a scripted geometry plug-in or as you said a scripted simple object , thanks for the tip
__________________
My Battersea power station project http://forums.cgsociety.org/showthr...p?f=43&t=666794

My Website
 
Old 01-19-2012, 05:04 PM   #8
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,865
Send a message via ICQ to denisT
Quote:
Originally Posted by denisT
old fashion smoke chimney

it's definitely the task for a Scripted Geometry Plug-in... or a Scripted SimpleObject...

http://forums.cgsociety.org/showthr...?f=98&t=1030472
 
Old 01-19-2012, 05:04 PM   #9
CGTalk Moderation
Expert
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,478
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 12:06 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.