sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Naming of new colours ??

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 2 Posters 166 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • artmusicstudioA Offline
      artmusicstudio
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        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...

        TIG

        1 Reply Last reply Reply Quote 0
        • artmusicstudioA Offline
          artmusicstudio
          last edited by

          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
          end
          
          

          thanx stan

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post
          Buy SketchPlus
          Buy SUbD
          Buy WrapR
          Buy eBook
          Buy Modelur
          Buy Vertex Tools
          Buy SketchCuisine
          Buy FormFonts

          Advertisement