Who could help to develop this rb?

Who could help to develop this rb?

Postby iApple » Sat Jun 01, 2019 2:45 am

Hi All, I found a "Layer Face Camera" plugin, and it's useful. But it can only turn off "always face camera". Who could help to add Switch ON/OFF function? Thank you very much.

# version:
# Added Undo

module JF
def self.layer_face_camera
layers = Sketchup.active_model.layers
name = UI.inputbox(["Layer"], [layers[0].name], [layers.map{|l|l.name}.join("|")])
return unless name
Sketchup.active_model.start_operation("Layer Face Camera")
Sketchup.active_model.entities.each { |ent|
next unless ent.is_a? Sketchup::ComponentInstance
next unless ent.layer.name == name[0]
cdef = ent.definition
cdef.behavior.always_face_camera = false
}
Sketchup.active_model.commit_operation
end
end
0

iApple 
 

Re: Who could help to develop this rb?

Postby sdmitch » Sat Jun 01, 2019 3:55 pm

Code: Select all
# version:
# Added Undo

module JF
  def self.layer_face_camera
    layers = Sketchup.active_model.layers
    name = UI.inputbox(["Layer:","On/Off:"], [layers[0].name,"Off"], [layers.map{|l|l.name}.join("|"),"On|Off"])
    return unless name
    Sketchup.active_model.start_operation("Layer Face Camera")
    Sketchup.active_model.entities.each { |ent|
      next unless ent.is_a? Sketchup::ComponentInstance
      next unless ent.layer.name == name[0]
      cdef = ent.definition
      cdef.behavior.always_face_camera = true if name[1]=="On"
      cdef.behavior.always_face_camera = false if name[1]=="Off"
    }
    Sketchup.active_model.commit_operation
  end
end

2
Nothing is worthless, it can always be used as a bad example.

http://sdmitch.blogspot.com/
User avatar
sdmitch 
PluginStore Author
PluginStore Author
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 



 

Return to Extensions & Applications Discussions

Who is online

Users browsing this forum: No registered users and 3 guests

Visit our sponsors: