sketchucation logo sketchucation
    • Login
    1. Home
    2. Koos Brandt
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
    K
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 3
    • Posts 10
    • Groups 1

    Koos Brandt

    @Koos Brandt

    10
    Reputation
    1
    Profile views
    10
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    Koos Brandt Unfollow Follow
    registered-users

    Latest posts made by Koos Brandt

    • RE: Ruby Tutorial: How to create and add a component from Ruby

      Hi

      I know it is nearly a year later, but your code is not doing what you think it is doing.

      Box4 does the following logically:

      It creates a component def
      Then you add 1 face to it and pull the face to make a block
      then you add this component as an instance

      then you add another face to it and pull it making block 2
      then you add another instance. But you also update the original instance to now have two blocks

      and so on

      if you set it to have 3 by 3 blocks you get 9 components all the same with each nine pulled faces inside it. The inside blocks are not component instances, the are merely blocks (pulled faces) inside the component.

      If you select the block at the end of the process and move it you will see there are more blocks underneath it.

      If you wanted to do what you intended, you needed to create a new component def each time you enter the upto loop.

      posted in Developers' Forum
      K
      Koos Brandt
    • RE: Scale tool

      I think the move idea explained above is neat for certain things, but not for others.

      I draw a lot of custom cabinets, and I draw them as separate board pieces making up the cabinet. Each board is a component by itself. This means I can easily edit the parent component and grad a child component and move it, but the other child components are no longer "glued" to the component being moved, and hence they do not strecth while moving the one child. It also means I have to individually grab the child pieces and "stretch" them (push pull) to "touch" the side moved.

      This would include doors, with maybe raised panels. Now I need to scale the cabinet in width and maybe depth, but I do not want my door stiles to change depth or width, nor do I want any of the boards to change thickness, same goes for the bevels on the raised panel.

      I've attached a Cabinet with glass shelves and the right side already moved to illustrate the issue.


      GlassShelveCab.jpg

      posted in Developers' Forum
      K
      Koos Brandt
    • RE: Nested Components

      Thanks guys, will try both ideas.

      RickW: The line was meant to be pseudo code. It sort of indicated what I wanted to do, but I also noted that there was no definitions within a definitions.

      Both Ideas make sense, ie it is similar to how you actually create it in SketchUp itself. Add a component inside the component. Logically I thought you had to create it inside, then add the geometry, but it is actually the other way around, create the definition, then add it to the parent.

      TIG's idea might actually be the simplest, because most sample code uses the add_group approach. So if you can later just change the group to a component, that seems rather simple.

      posted in Developers' Forum
      K
      Koos Brandt
    • Nested Components

      I am using the following code from Todd as a starting point

      # Written by Todd Burch   www.smustard.com    June 23, 2007. 
      
      # First, create a new Component Definition.
      new_comp_def = Sketchup.active_model.definitions.add("MyCube") ; 
      
      # Now, define some points for an arbitrary face. 
      points = Array.new ; 
      points[0] = ORIGIN ; 
      points[1] = [100, 0  , 0] ; 
      points[2] = [100, 100, 0] ; 
      points[3] = [0  , 100, 0] ; 
      
      # Now, add the face to the new component definition. 
      newface = new_comp_def.entities.add_face(points) ;   # returns a Face
      
      # If the blue face is pointing up, reverse it.  
      newface.reverse! if newface.normal.z < 0 ;  # flip face to up if facing down
      
      # pushpull the face into a Cube 
      newface.pushpull(100) ; # extrude it up to make a cube 
      
      # To add the component, you have to define a transformation.  We can define 
      # a transformation that does nothing to just get the job done. 
      trans = Geom;;Transformation.new ;    # an empty, default transformation. 
      
      # Now, insert the Cube component. 
      Sketchup.active_model.active_entities.add_instance(new_comp_def, trans) ; 
      
      #done. 
      
      

      What I would like to do is actually add a new component within the component I am creating. I looked at lost of scripts, but everybody seems to just do add_group.

      The idea would be to create new_comp_def = model.definitions.add
      then create new_sub_comp_def = new_comp_def.definitions.add

      now at the end one should probably have
      new_comp_def.entities.add_instance(new_sub_comp_def,trans)
      model.active_entities.add_instance(new_comp_def,trans)

      or similar.

      Anybody with guidance here?

      posted in Developers' Forum
      K
      Koos Brandt
    • RE: Smooth Texture on Curved Surface

      Thanks for the info.

      I can now recreate what you have done. I just draw a curve, and close it, no welding, the arc stays an arc. I then use extrude to create the surface and afterwards the texture works fine.

      What I was actually doing to create the extruded shape was rather different, and it might have something to do with it.

      I create an arc just as a guideline for a follow me. Then I create an Upright Rectangle, and follow it along the arc. The reason for this was of how my Ruby script work. I have to create a lot of components that follows basically the same curve, ie curved panels, with mouldings, etc. It seems that in that case, the resulting follow me creates the "segments" somewhat differently, and hence the texture problem. This might mean some rethink on my approach.

      posted in SketchUp Discussions
      K
      Koos Brandt
    • RE: Smooth Texture on Curved Surface

      What exactly do you mean with resample the texture and it will wrap.

      It seems to do something, but not entirely.

      Attached the document, using a texture from SU itself.

      I draw, unhide geometry, select a segment, set projected. Hide geometry again.

      From the left it looks like the texture is "projected" but from about the middle it seems repeating again.


      CurvedTexture.skp

      posted in SketchUp Discussions
      K
      Koos Brandt
    • Smooth Texture on Curved Surface

      I want to create a curved surface, extruded from an arc, and then apply a surface material to it.

      Problem is that the curved part is treated as many separated sections, each getting a copy of the same part of the texture.

      Is there a way around this problem?

      I am doing all of this in Ruby, ie create an edge, then do a follow me along that edge using an upright rectangle. I can apply material to the resulting extruded shape, but the many sections create a bit of an unnatural look.

      If anybody knows how to do this normally, ie not ruby, I can probably repeat that inside the ruby.

      posted in SketchUp Discussions sketchup
      K
      Koos Brandt
    • RE: Webdialog and active_model

      Confitex

      Sorry, But I cannot post the ruby code here. It is done for a customer and at this stage it is aimed and giving them something not really available. Cannot give away their business edge

      I am willing to answer questions about specifics, like in your post about webdialog and SU parameters. To obfuscate the whole ruby script, and still keep it as working will be a "big" task.

      What are you having problems with, or what specifically do need help with?

      posted in Developers' Forum
      K
      Koos Brandt
    • RE: Webdialog and active_model

      Thanks

      It works like a charm!

      posted in Developers' Forum
      K
      Koos Brandt
    • Webdialog and active_model

      I've searched but don't seem to get the right info.
      I have a webdialog where i set parameters and press a button to update
      the active_model. Currently I just draw a box.
      The Webdialog stays active, so you can change the settings again.
      The problem is that unless I select the active model window(using the
      mouse) the drawing does not appear. It seems becuase I am drawing to
      active-model, but active-model is "inactive" while I am on the
      webdialog, the drawing happens in the background.
      I call the following

       component = Sketchup.active_model.definitions.add("MyLeftSide") 
       trans = Geom;;Transformation.new 
       instance = 
      Sketchup.active_model.active_entities.add_instance(component, trans) 
       newface = component.entities.add_face(@p) ;   # returns a Face 
       newface.reverse! if newface.normal.z < 0 ;  # flip face to up if 
      facing down 
       newface.pushpull(@height) ; # extrude it up to make a cube 
      

      where @p is an array of points. The code basically works and draws the
      correct block, but just not while the WebDialog is the active window!
      So little help on using the webdialog stuff. Anybody?

      posted in Developers' Forum
      K
      Koos Brandt