Naming of new colours ??
-
hi there,
i declare my colours to my group's elements like this:
@c_carrier = Sketchup;;Color.new(112,128,144) # @group41.entities.grep(Sketchup;;Face).each{|f| f.material=@c_carrier }wherever i looked for it, i cannot find any syntax for asigning additional colour-name , which appears in the colour-list (model's materials).
a name is important in the dae-transfer to a vis-software, so i would like to create unique names for fixed material asignment in my vis.
any idea?
thanx a lot
stan -
Please don't confuse color and material.
If you specify a material using a standard color name like 'red' you get that material named 'red' and it has the color RGB [255,0,0] taken from the color 'red'.
It's much easier to separate material and color inside your own efforts...So I think you'll be happier if you first make the new material by name [unless it already exists], then assign the desired color to that material... then assign that material to geometry, groups etc...
model = Sketchup.active_model materials = model.materials material_name = "MyLovelyNewMaterialName" unless material = materials[material_name] material = materials.add(material_name) end ### makes 'material' using 'material_name' if it doesn't already exist... material.color = Sketchup;;Color.new(112, 128, 144) ### now add 'alpha', 'texture' etc to the 'material' as desired... ### then later @group41.entities.grep(Sketchup;;Face).each{|f| f.material = material }Note: use '@' type variables if they are used across several def methods...
-
hi tig,
understood, works perfect !model = Sketchup.active_model materials = model.materials names = ["zf_carrier", "zf_step", "zf_landing", "zf_fill", "zf_wange", "zf_pfosten", "zf_handlauf", "zf_bars", "zf_topstift", "zf_railplate"] color_val = [[112,128,144],[200,220,200],[230,230,230],[100,120,100],[255,0,0],[0,255,0],[0,20,255],[10,10,10],[60,180,180],[0,206,209]] zf_c = 10 for col in 0..zf_c-1 if @pref2 == "no" #option for the user for coloured screen output (in my ruby-preferences) material_name = names[col] unless material = materials[material_name] material = materials.add(material_name) end material.color = Sketchup;;Color.new color_val[col] elsif @pref2 == "yes" #option for the user for monochrome screen (in my ruby-preferences) material_name = names[col] unless material = materials[material_name] material = materials.add(material_name) end material.color = Sketchup;;Color.new(230,230,230) end endthanx stan
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement