sketchucation logo sketchucation
    • Login
    1. Home
    2. Andreas
    3. Posts
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    ⚠️ Important | Libfredo 15.6a introduces important bugfixes for Fredo's Extensions Update
    A
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 11
    • Posts 36
    • Groups 1

    Posts

    Recent Best Controversial
    • RE: Layer color by ruby-code?

      @thomthom said:

      would help if we got the whole error - with the line number and traceback

      The file "test.rb" is in plugins folder.
      That´s the whole code of test.rb

        model = Sketchup.active_model
        layer = model.layers.add "ABS_Grundriss_Wand2"
        layer.color = [255,255,255]
      
      

      The following error message appears if Sketchup start:
      %(#FF0000)[Fehler beim Laden der Datei test.rb
      undefined method `page_behavior=' for nil:NilClass]

      That error appears in context with "layer-color=.rb" which is in
      plugins folder too. If I remove "layer-color=.rb" from plugins folder
      there is the following error message:
      %(#FF0000)[Fehler beim Laden der Datei test.rb
      undefined method `color=' for #Sketchup::Layer:0x6dfe1ec]

      That error I understand.

      posted in Developers' Forum
      A
      Andreas
    • RE: Layer color by ruby-code?

      @tig said:

      Have you restarted SUp after installing the new code script ?

      Yes

      posted in Developers' Forum
      A
      Andreas
    • RE: Layer color by ruby-code?

      @tig said:

      There is no built-in API layer.color=
      BUT see here for my stop-gap new method... http://forums.sketchucation.com/viewtopic.php?p=177016#p177016
      with that loaded your example layer.color= [255,255,255] should work...

      I tried that. I copied "layer-color=.rb" to plugins folder.
      And than there was the error when I start my code.
      What is the mistake I made?

      posted in Developers' Forum
      A
      Andreas
    • RE: Layer color by ruby-code?

      😢 😢 😢 😢 😢 😢 😢

      I tried it with "layer-color=.rb"

      
        layer = model.layers.add "my_layer"
        layer.color = [255,255,255]
      
      

      But there is the following error:
      "undefined method `page_behavior=' for nil:NilClass"

      Do you have an idea why the error occurs?

      posted in Developers' Forum
      A
      Andreas
    • Layer color by ruby-code?

      Is it possible to set the layer color by ruby-code?

      posted in Developers' Forum
      A
      Andreas
    • RE: Soften-Edges using by ruby

      @tig said:

      Make an array of the selected edges [or of the edges within selected groups etc].
      Iterate through those edges and test it they have >1 face.
      Soft/Smooth them...

      
      > def makesoftsmooth()
      >  model=Sketchup.active_model
      >  ss=model.selection
      >  ### You can assemble any collection of edges
      >  ### Here it's from the model's current selection
      >  edges=[]
      >  ss.to_a.each{|e|
      >    edges << e if e.class==Sketchup;;Edge
      >    e.entities.each{|ee|edges << ee if e.class==Sketchup;;Edge}if e.class==Sketchup;;Group
      >  }
      >  edges.each{|edge|
      >    if edge.faces[1]
      >      edge.soft=true
      >      edge.smooth=true
      >    end
      >  }
      > end#def
      > 
      

      Save code as makesoftsmooth.rb or use the def as part of a broader tool.
      Execute it as makesoftsmooth()
      ...

      Thank you!
      That works well, if the edges not in a group.
      But on edges in a group it doesn´t work.
      What should I do so that it acts on the edges in a group?

      posted in Developers' Forum
      A
      Andreas
    • RE: Soften-Edges using by ruby

      @jim said:

      ... you will need to write your own soften method.

      How does it work? Do you have an idea?

      posted in Developers' Forum
      A
      Andreas
    • Soften-Edges using by ruby

      I want to use the menu command "Soften Edges" from the "Window"-menu by ruby.
      Can someone tell me how does it work?

      posted in Developers' Forum
      A
      Andreas
    • Add a group to another group by rupy-code

      Hi,

      I would like to insert "Group1" into "Group2" by ruby-code.
      What should I do to make this work?

      posted in Developers' Forum
      A
      Andreas
    • RE: Edit group by ruby-code instead of a right mouse click

      @thomthom said:

      my_group = all_groups.select{|g| g.name == "G1"}.first

      Thanks - that´s exactly what I need!!! 😄

      posted in Developers' Forum
      A
      Andreas
    • RE: Edit group by ruby-code instead of a right mouse click

      @tig said:

      ...Assuming you corrected the group >> my_group it should work IF the names match... 😕

      It does not work.

      all_groups = Sketchup.active_model.entities.find_all{|e| e.class == Sketchup;;Group}
      my_group = all_groups.select{|g| g.name == "G1"}
      my_entities = my_group.entities
      
      

      The result is:

      all_groups = Sketchup.active_model.entities.find_all{|e| e.class == Sketchup::Group}
      finds several groups
      => [#Sketchup::Group:0x80db350, #Sketchup::Group:0x80db320, #Sketchup::Group:0x80db2f0, #Sketchup::Group:0x80e6768]

      my_group = all_groups.select{|g| g.name == "G1"}
      picks one of the groups
      => [#Sketchup::Group:0x80e6768]

      my_entities = my_group.entities
      gives the following error
      NoMethodError: (eval):1:in get_binding': undefined method entities' for [#Sketchup::Group:0x80e6768:Array]

      I don`t understand that!!!

      Is there anybody who can explain it to me?

      posted in Developers' Forum
      A
      Andreas
    • RE: Edit group by ruby-code instead of a right mouse click

      @tig said:

      You first get a reference to the required group, then one to its entities, and then do stuff in that entities collection...
      To see if each step is working add puts my_group etc after it's defined it should then print up the group-id in the ruby console or 'nil'!
      It should be my_group in your code if you want to work inside that group.
      Do you have a group with that specific name ?
      Obviously the .add_face(...) needs expanding so the ... is a list of at least three coplanar points!!
      It WILL work...
      Why not test it using my method that adds a new group to model.active_entities with
      my_group=model.active_entities.add_group()
      NOW you are sure to have my_group... now add the face to my_group.entities

      Hello TIG,

      I need access to an existing group to add a face. I would like to make a cutout in a wall (existing group) to insert a door or window.

      Andreas

      posted in Developers' Forum
      A
      Andreas
    • RE: Edit group by ruby-code instead of a right mouse click

      @jim said:

      You work directly with the Group's entities, just like you would the model's entities. Having an editing context is a useful concept for people when modeling, but is not necessary when editing geometry using the Ruby API.

      This sample shows how you might get to a Group's entities.

      
      > all_groups = Sketchup.active_model.entities.find_all{|e| e.class == Sketchup;;Group}
      > my_group = all_groups.select{|g| g.name == "My Group"}
      > my_entities = group.entities
      > my_entities.add_face(...)
      > 
      

      my_entities = group.entities don´t works.
      I think it must be:
      my_entities = my_group.entities
      but that don´t works too.

      Can someone help me?

      Thanks
      Andreas

      posted in Developers' Forum
      A
      Andreas
    • RE: Edit group by ruby-code instead of a right mouse click

      I would like to make a cutout in a wall (group) to insert a door or window.

      Andreas

      posted in Developers' Forum
      A
      Andreas
    • Edit group by ruby-code instead of a right mouse click

      Hi!

      Is it possible to edit a group by ruby-code instead of a right mouse click in contextmenu.

      Thanks...

      Andreas

      posted in Developers' Forum
      A
      Andreas
    • Select a Group in Ruby code instead of using the mouse

      Hi,
      I generate plugin by various parts and then summarize them into one group.
      This works very well:

      mogroup = entities.add_group elements

      Now I want to pick this group also right at the end of the plugin via Ruby code. So I not have to select the just created group by using the mouse.

      Can anyone help me?

      Thank you!

      Greeting
      Andreas

      posted in Developers' Forum
      A
      Andreas
    • 1 / 1