Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
On 30/05/2014 at 08:08, xxxxxxxx wrote:
I have a lot of userdata controls that needs show/hide when pressing buttons. This is a sample of the code I am using and was wondering if there is maybe a shorter way of coding for this?????
#--Hide_Cone_Types-- if descId[1].id == 14: if Bolt_Fac[c4d.ID_USERDATA,20] == 0: container[c4d.DESC_HIDE] = True Bolt_Fac.SetUserDataContainer(descId, container) #--Hide_Cone_Height-- if descId[1].id == 16: if Bolt_Fac[c4d.ID_USERDATA,20] == 0: container[c4d.DESC_HIDE] = True Bolt_Fac.SetUserDataContainer(descId, container) #--Hide_Cone_Radius-- if descId[1].id == 18: if Bolt_Fac[c4d.ID_USERDATA,20] == 0: container[c4d.DESC_HIDE] = True Bolt_Fac.SetUserDataContainer(descId, container) #--Hide_Cone_Point_Height-- if descId[1].id == 25: if Bolt_Fac[c4d.ID_USERDATA,20] == 0: container[c4d.DESC_HIDE] = True Bolt_Fac.SetUserDataContainer(descId, container) #--Hide_Indented_Height-- if descId[1].id == 21: if Bolt_Fac[c4d.ID_USERDATA,20] == 0: container[c4d.DESC_HIDE] = True Bolt_Fac.SetUserDataContainer(descId, container) #---Hide_Dome_Height--- if descId[1].id == 23: if Bolt_Fac[c4d.ID_USERDATA,20] == 0: container[c4d.DESC_HIDE] = True Bolt_Fac.SetUserDataContainer(descId, container)
On 30/05/2014 at 08:52, xxxxxxxx wrote:
Maybe like this.
hide_items = [ 14, # Hide_Cone_Types 16, # Hide_Cone_Height # ... ] if Bolt_Fac[c4d.ID_USERDATA, 20] == 0: for item in hide_items: if descId[1].id == item: container[c4d.DESC_HIDE] = True
Or maybe you better use
hide_items = [ 14, # Hide_Cone_Types 16, # Hide_Cone_Height # ... ] for item in hide_items: if descId[1].id == item: container[c4d.DESC_HIDE] = (Bolt_Fac[c4d.ID_USERDATA, 20] == 0)
so that the elements will be shown again when UD #20 is not zero.
On 30/05/2014 at 09:01, xxxxxxxx wrote:
Hi NiklasR. Like I said this is just a sample of the code. There is a code to unhide them thats why I want to put it in a shorter code. Sorry I'm still learning python and would like a sample code pls That's how I'm learning python
On 30/05/2014 at 09:04, xxxxxxxx wrote:
Thanks NiklasR. Ignore my previous post you rock _<_img src="http://www.c4dcafe.com/ipb/public/style_emoticons/default/thisrocks.gif" border="0" alt=":thisrocks:" title=":thisrocks:" /_>_
On 30/05/2014 at 09:37, xxxxxxxx wrote:
You're welcome. Sorry I changed my original post for that much.
This one's better (in terms of speed)
hide_items = frozenset([ 14, # Hide_Cone_Types 16, # Hide_Cone_Height # ... ]) if descId[1].id in hide_items: container[c4d.DESC_HIDE] = (Bolt_Fac[c4d.ID_USERDATA, 20] == 0)
-Niklas