Random color script

Next
 From:  Frenchy Pilou (PILOU)
3876.1 
Does it possible to have a script that attribute a random color to a general selection
with different colors to types?
(Curve,surface,edge,faces) not solid because it's yet attributed by the previous type ;)

Or maybe this previous exists, i don't remember ?
Attachments:

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
3876.2 In reply to 3876.1 
Hi Pilou, I'm not actually sure what you are describing, because you mention both assigning a color randomly and at the same time you seem to be asking about assigning specific colors to types which then does not sound random to me.

There is a script that will randomize the colors of your styles though if that is of any help, that's available here:
http://moi3d.com/forum/index.php?webtag=MOI&msg=2987.2

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Frenchy Pilou (PILOU)
3876.3 In reply to 3876.2 
< a color randomly and at the same time you seem to be asking about assigning specific colors to types which then does not sound random to me.

look at the previous cube : it has different colors for the edges, and different colors for the faces
so each types has different colors in the same time ;)

In some program no random colors gives for example axes direction : red, green, blue as X,Y, Z
so you can easily see if your volumes is // to the axes :)

here it's just for artistic purpose like a Mondrian over steroïded :)

PS Thx for the remember color post :)

EDITED: 26 Nov 2010 by PILOU

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
3876.4 In reply to 3876.3 
Hi Pilou, well right now colors in MoI are defined by styles. So if you wanted a different random color for every single edge within a solid that would mean creating a huge number of styles - one for every single edge. That's not really a very good structure...


> In some program no random colors gives for example
> axes direction : red, green, blue as X,Y, Z

Well, one problem with that is that many kinds of objects may be made up of curved edges, not only straight lines. A curved edge does not have any single direction to it like a line does.

So speaking of the "axis direction" of an edge does not really apply to the general case of any kind of edge - it's only some special subset of edges that have such a concept associated with them.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Frenchy Pilou (PILOU)
3876.5 In reply to 3876.4 
< That's not really a very good structure

Yes but not important, it's just for "artistic purpose" result ;)
so only face or surface will be sufficient :)

EDITED: 26 Nov 2010 by PILOU

Attachments:

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
3876.6 In reply to 3876.5 
Hi Pilou, right now MoI is not really set up to generate images directly...

Is it possible for you to export your MoI model into SketchUp and then assign random colors for a screenshot inside of there? It kind of looks like you might have some method in SketchUp for that already.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Frenchy Pilou (PILOU)
3876.7 In reply to 3876.6 
Of course yes I can ;)
It was for win a step :)
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
3876.8 In reply to 3876.7 
Hi Pilou, so exporting to SketchUp is probably your best bet for this - the script that would be created in MoI for full color randomization of every single sub-object would be awkward since it would involve creating a huge number of styles.

Maybe in the future there will be some way to assign a color to an object directly overriding its style assignment but currently it is not set up that way.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Frenchy Pilou (PILOU)
3876.9 In reply to 3876.8 
No problem :)
And just one random color for a solid or by object or by object?

EDITED: 26 Nov 2010 by PILOU

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
3876.10 In reply to 3876.9 
Hi Pilou, so I was thinking - do you really need a completely different random color for every single thing? What if it was more like 20 different base colors which were then randomly assigned? That would be a lot easier to set up because that would only involve creating 20 styles.

So the way that would work would be to first set up 20 different styles, and you can assign them the colors that you want, or use the script from here to randomize their colors:
http://moi3d.com/forum/index.php?webtag=MOI&msg=2987.2


Then you can use the following script on a shortcut key to randomly assign each face or edge to one of those styles:

script: /* Assign random styles to faces and edges */ var styles = moi.geometryDatabase.getObjectStyles(); var breps = moi.geometryDatabase.getObjects().getBReps(); for ( var i = 0; i < breps.length; ++i ) { var brep = breps.item(i); var edges = brep.getEdges(); for ( var j = 0; j < edges.length; ++j ) { edges.item(j).styleIndex = Math.floor(Math.random() * styles.length); } var faces = brep.getFaces(); for ( var j = 0; j < faces.length; ++j ) { faces.item(j).styleIndex = Math.floor(Math.random() * styles.length); } }


You can also just use this with the default set of styles as well, it will randomly assign each face or edge to one of the current style colors. Then if you want more variety add more styles.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Frenchy Pilou (PILOU)
3876.11 In reply to 3876.10 
Thx I will see that as soon as possible :)
---
Pilou
Is beautiful that please without concept!
My Gallery
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Frenchy Pilou (PILOU)
3876.12 
Works like a charme! You rocks!
http://moiscript.weebly.com/randomcolor.html
Speedy test!
Ps No problem but there is a white color who is not inside the default Style


EDITED: 28 Nov 2010 by PILOU

Attachments:

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
3876.13 In reply to 3876.12 
Hi Pilou, I'm glad that will work for you!

> Ps No problem but there is a white color who is
> not inside the default Style

What options do you have enabled under Options > View > Lighting options, did you turn on the option for "Specular highlights" in there?

That option makes white shiny spots on objects, so turn that off.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Frenchy Pilou (PILOU)
3876.14 In reply to 3876.13 
Yes it was some enable Metallic Lights :)
---
Pilou
Is beautiful that please without concept!
My Gallery
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Frenchy Pilou (PILOU)
3876.15 
Seems Styles are losted when you export as SKP file
Is that normal?
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
3876.16 In reply to 3876.15 
Hi Pilou, yes currently styles are not exported to SKP format.

One reason for that was that I wasn't sure how they should be exported - SketchUp has a couple of different ways for assigning colors, there are both Layers and Materials.

I think with the previous discussion here:
http://moi3d.com/forum/index.php?webtag=MOI&msg=3790.16 it was resolved that Layers are not generally used in SketchUp so that styles should be exported as Materials. That's something that I will be trying to add in for MoI v3.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Frenchy Pilou (PILOU)
3876.17 In reply to 3876.16 
Cool :)
---
Pilou
Is beautiful that please without concept!
My Gallery
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  NightCabbage
3876.18 
Hehe, yes, I'm also very interesting in coaxing Michael into adding basic rendering into MoI :)

(even for 2d stuff)

Would cut out 2 or 3 programs in my workflow LOL
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All