Jump to content


Photo

Changing Component Parameters At Runtime


  • Please log in to reply
8 replies to this topic

#1 swzone

swzone

    Member

  • Members
  • PipPip
  • 21 posts

Posted 05 May 2012 - 06:26 AM

Hello,

Is there any way to change component parameter at runtime ? by using code ?

I want to change the Frames parameter of fuse component using code.
also I want to change SegmentAngle of Toroid_segment component using code.

Thanks

#2 glsmall

glsmall

    Advanced Member

  • Members
  • PipPipPip
  • 1457 posts
  • Gender:Male
  • Location:Spring, TX
  • Interests:Dancing, Genealogy, Web Design

Posted 05 May 2012 - 09:26 AM

Check the script in Scene_1
Attached File  fuse.swi   17.36KB   31 downloads

Edited by glsmall, 05 May 2012 - 09:27 AM.

The latest SWiSH Max build is "pinned" near the top of the BUGS forum (SM2) (SM3) (SM4)
Posted Image

#3 swzone

swzone

    Member

  • Members
  • PipPip
  • 21 posts

Posted 05 May 2012 - 05:13 PM

Hi glsmall,

Thanks for your code,

Where can I find detail info about component methodes,events and parameters ?

Regards.

#4 swzone

swzone

    Member

  • Members
  • PipPip
  • 21 posts

Posted 05 May 2012 - 05:25 PM

If there is no direct way to change component parameter at runtime ,

is it possiple to create component at runtime with intilazied paramters ?

#5 glsmall

glsmall

    Advanced Member

  • Members
  • PipPipPip
  • 1457 posts
  • Gender:Male
  • Location:Spring, TX
  • Interests:Dancing, Genealogy, Web Design

Posted 06 May 2012 - 12:19 AM

I guess I don't understand because the example I posted set the Frames parameter at run time. So I guess the simple answer is yes but it may require some scripting. Please explain and give some detail as to what you are trying to achieve.

Also, it would be good if you could post your swi so whomever may work on your request desn't have to create something from scratch. ;)
The latest SWiSH Max build is "pinned" near the top of the BUGS forum (SM2) (SM3) (SM4)
Posted Image

#6 glsmall

glsmall

    Advanced Member

  • Members
  • PipPipPip
  • 1457 posts
  • Gender:Male
  • Location:Spring, TX
  • Interests:Dancing, Genealogy, Web Design

Posted 06 May 2012 - 12:28 AM

Oh, and as far as learning about components...

The latest SWiSH Max build is "pinned" near the top of the BUGS forum (SM2) (SM3) (SM4)
Posted Image

#7 swzone

swzone

    Member

  • Members
  • PipPip
  • 21 posts

Posted 07 May 2012 - 04:49 AM

Thanks for links and tutorials ,

I can access and read the Frames parameter using fuse.parameters.Frames
But changing Frames value does not refelect to internal script ,
Yes your code is working well, but how about other compenet like SegmentAngle of Toroid_segment ? or any other compenet parameters ?
I dont want to go inside the creating script.

Regards

#8 glsmall

glsmall

    Advanced Member

  • Members
  • PipPipPip
  • 1457 posts
  • Gender:Male
  • Location:Spring, TX
  • Interests:Dancing, Genealogy, Web Design

Posted 07 May 2012 - 04:59 AM

If the component doesn't have the functionality you need and you don't want to go in and modify the script then it may not be possible. I tend to think of the included components as a good starting point and if I need some functionality that the component isn't designed for I either modify it or design my own. I don't know what else to say. I guess I don't understand why you would not want to modify the script if it would get it to do what you want.
The latest SWiSH Max build is "pinned" near the top of the BUGS forum (SM2) (SM3) (SM4)
Posted Image

#9 OutCast**NL

OutCast**NL

    Advanced Member

  • Members
  • PipPipPip
  • 692 posts
  • Gender:Male
  • Location:NL

Posted 07 May 2012 - 06:37 AM

Parameters are basicly just initial values,.. and values can be changed.
The problem here is that some components refer directly to the hardcoded parameters like ie:

if (!parameters.Repeat){...

instead of storing the parameters value in a var first, like ie:

myvar = parameters.Repeat;
if (!myvar){...

using the last scenario,
changing value of "myvar" will overwrite the value from the parameters panel.

;)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users