sketchucation logo sketchucation
    • Login
    1. Home
    2. NewOne
    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!
    πŸ”Œ Easy Offset | Offset selected faces in SketchUp in positive and negative offsets. Download
    N
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 59
    • Posts 317
    • Groups 1

    Posts

    Recent Best Controversial
    • RE: [IDEA] Fish skin

      better and easier way is to use a rendering engine which supports normal mapping or displacement maps.

      1. the model will be smaller and easier to work with
      2. there will be less polygons -more speed in rendering
      3. is easier to map a texture than create so many shapes on a irregular surface
      4. if you want the shapes to not be identical, but to have small differences (the scales on a fish are not identical one with other...let's say) -just take a photo of the wanted surface and edit it. And you can have it for later use.

      ...on the other hand, there is a script drop.rb made by TBD. It can be adapted to drop shapes on a surface and then to rotate those shapes according to surface's normal in the drop point. And you have a way to "seed" shapes on surface πŸ˜›

      ..just some ideas, please don't judge me πŸ˜„

      posted in Developers' Forum
      N
      NewOne
    • Full ruby documentation for SU7?

      Does somebody know if there is a full ruby documentation for SU7? Or we have to wait?
      Thanks

      posted in Developers' Forum
      N
      NewOne
    • RE: Ruby scripting interface

      notepad++ πŸ˜‰ it's nice.
      And it have some nice global variables that you can use. example: press F6 and write

      ruby "$(FULL_CURRENT_PATH)"
      

      than you can save this for further use and add a shortcut key. In this way you will run your ruby program in notepad++ native console (instead of CMD).
      For SketchUP scripts you can try this: http://www.errorinitus.de/sketchup/dcode/help/1.0_RC1/index_en.html

      have phun! πŸ˜›

      posted in Developers' Forum
      N
      NewOne
    • RE: Boundingbox.width (height, depth) related to global axes?

      @cphillips said:

      Use the bounding box from the definition

      componentinstance.definition.bounds
      

      Note: if your component instance is scaled you will need to scale the bounds the same amount.

      Thanks a lot ! You made my day β˜€

      posted in Developers' Forum
      N
      NewOne
    • Boundingbox.width (height, depth) related to global axes?

      Hello people!
      In atempt to get a component's dimension I used:

      
      ...
      z = bbox.depth
      x = bbox.width
      y = bbox.height
      ...
      
      

      But I've seen that depth, width and height are not related to component's axes, but to global axes!
      see the links: http://bayimg.com/FAlhMaAbk and http://bayimg.com/fAlHoAABk
      Same component, rotated in drawing space returned different dimensions. (see result in Ruby Console)
      I want to get axes-based dimendions of the component (component's axes). If blue is on 50mm edge, I want to have z=50mm, and so on.
      Does somebody have some ideas about how can be this done?

      Thanks!

      posted in Developers' Forum
      N
      NewOne
    • RE: Ruby challenge 2 ?

      @unknownuser said:

      I know anything of the ruby scripting 😳
      but seems to me that when you select a volume there is a blue bounding box around the volume done by SU πŸ˜’
      Just take it the 8 vertices and you have your list πŸ’š (or 4 for a surface in 2D)
      I don't know if that is cheating πŸ˜„

      The BoundingBox is related to global axes! so if your face is oblique, the boundingbox means the projection on the axes. That's not helpfull because doesn't represent the real size of the face.

      posted in Developers' Forum
      N
      NewOne
    • RE: Ruby challenge 2 ?

      @matt666 said:

      Hi all !
      I really HOPE that no one can do this with native ruby codes πŸ˜„ πŸ˜„ !!

      I start this challenge because I don't know how to do that... In fact, I have a little idea πŸ˜†
      This challenge is to do a script that returns a list of 4 points which represent mounting space of the face.
      Exemples :[attachment=1:1f1b2ici]<!-- ia1 -->Sans titre 1.jpg<!-- ia1 -->[/attachment:1f1b2ici]
      SU file is attached.

      Is it instersting? Is it an idea worthy of a challenge? I would like to have your opinions !

      Thank you !

      Check "Rotate a texture" topic... i put there something that fits what you want. Just the ideea... maybe will come the script, but for now I'm working to something else. Perhaps somebody else will try a script based on that.

      posted in Developers' Forum
      N
      NewOne
    • RE: Rotate a texture

      @unknownuser said:

      You have mentioned about UVHelper but you are not using it in the script. I would like to learn how to use it efficiently also with nested faces and will contribute to this thread as much as I will be able to.

      You are right! I didn't used UV helper and you have the answer why in those posts. As I seen since now, for SU, the priority is the tiling of texture on surface, although you enter the size of the tile in texture editor. So, that's why we need to know the overall dimensions of the face. If the face is normal-to-axis is simple: you use face.bounds. But for a randomly oriented face we must calculate the vertex distance.
      I have an ideea: it came on-the-fly πŸ˜„... to use UV helper to retrieve the position of all vertexes of the face. Then calulate the projection from boundingbox center to farthest vertex in two perpendicular directions.

      center = face.bounds.center
      

      Then, having this, is easy to know the overall dimensions of the face and the ratio (ratio = fasce_dimension / texture_dimension) to preserve same tiling when rotating. If you don't do this, the texture will shrink. texture shrinks if don't preserve the ratio
      After that, one of the vertexes is rotated around the normal to face with desired angle. And that's how the texture can be rotated on randomly oriented face !
      this is a strange shape face, to make things messy ;)
      Or, maybe it's a easier way to do this... I mean to work on triangulated or quadrilateral faces, but there Open GL must be used, I think.

      Some suggestions from The Big Ones? πŸ’š

      posted in Developers' Forum
      N
      NewOne
    • RE: SketchUp RUBY API Wishlist [way of coding wishes, please]

      Move (and rotate) axes from ruby !!! Actually, to be able to access any tool from ruby.

      regards!

      posted in Developers' Forum
      N
      NewOne
    • RE: Change axes from ruby

      @cphillips said:

      As far as I know the only way to "move an axis" in Sketchup is to move all the entities in the component so they are centered around the desired axis. That is what the function does.

      I've seen that. So, rotating the axis to obtain a different boundingbox see here: http://bayimg.com/BaLOIaABJ can be done in the same way? Using a transformation that rotates all entities in the component around the origin, then rotates the component back in its initial position?

      P.S. what BillW wanted to say with

      Sketchup.send_action("selectAxisTool;") if @rotate
      status = model.place_component modcomp, false
      

      ? πŸ˜’
      Easy things for you people as pure chinese for me, a newbie 😳

      posted in Developers' Forum
      N
      NewOne
    • RE: Rotate a texture

      @psychomuffin said:

      Please excuse my lack of understanding, but how does one take the code you provided, and turn it into a plugin? Does it need compiling or anything? I really don't know anything about ruby... sadly.

      Thanks

      Copy all that text and paste it in a notepad file. Rename that file with " texture_rotator.rb " (see the last lines of the code that add a entry in Plugins menu) and put your newly created file in the Plugins folder of SU.
      Carefull with copying to not miss something.
      Enjoy!

      Sketchup have built-in ruby interpreter, so what you need is just the code. Ruby is an interpreted language (like Fortran if you want), not a compiled one like C.

      Be aware that this script rotates the texture on the face, not on the component (or group). So you must apply the material directly on face.

      posted in Developers' Forum
      N
      NewOne
    • RE: Tool in another tool

      @matt666 said:

      Hi !
      Can anyone tell me how to create a script that not stops a tool already in use ?
      Which functions should I use ?

      Exemple :

      • Start line tool
      • Place the first point
      • Start zoom window tool and zoom somewhere in the drawing
      • Place the end point of the line. Zoom window tool has not annulate line tool...

      Sketchup does this without need of any rubyscript... I have started LineTool, placed the first point (click-release), then went on "Camera" Toolbar, clicked on Zoom Window icon (also works with Ctrl+Shift+W from keyboard), zoomed on a certain spot on the viewport and placed the second point of the line. It worked!

      posted in Developers' Forum
      N
      NewOne
    • RE: Change axes from ruby

      @cphillips said:

      Here is a function to reset the components axis to the bounding box center.

      Thanks CPhillips ! the code works great!
      So, if I understand correctly, you can't move axi's origin in SU, instead the boundingbox can be manipulated around its origin, right?

      posted in Developers' Forum
      N
      NewOne
    • RE: Change axes from ruby

      @billw said:

      The way I got around the problem in one of my tools was to call the axes tool as shown below

      Sketchup.send_action("selectAxisTool:") if @rotate
      status = model.place_component modcomp, false

      Regards

      Bill Wood

      Would you, please explain me a little bit more? I'm on my first steps in programming.
      Thank you!

      posted in Developers' Forum
      N
      NewOne
    • RE: Rotate a texture

      Here is a scipt that rotates a texture on a face by a custom angle.
      For now, the script works just for faces in xy plane (red-green) but it can be a usefull example to understand how to position a texture on a face.
      The UV helper retrieves the vertex coordinates. So, if you have a hexagonal face, you will have 12 points (6 vertexes). But position_material method uses maximum 8 points (4 vertexes)... This is because Open GL treats any surface as a composition of triangles or quadrilaterals (sorry if misswriten). This is why i don't know yet how to make the script working for faces oriented arbitrary (not normal on an axis). I use the entitie's boundingbox as a reference.

      For better understanding of what I've done, see this image http://bayimg.com/bALMEaABJ

      require 'sketchup.rb'
      
      def rotate_texture
      prompts = ["rotation angle "]
      value = [0.0]	#use float for better precission
      result = inputbox prompts, value, "Texture Rotator"
      return if not result
      angle = result
      #------------------------------------------------------------------------------------------------------
      
      ox = Math.cos(angle[0].degrees) #projection coefficient
      oy = Math.sin(angle[0].degrees)	#projection coefficient
      		
      selected = Sketchup.active_model.selection[0]
      
      	if( selected.is_a? Sketchup;;Face ) #check if you selected a face
      		
      		boundingbox = selected.bounds
      		material = selected.material
      		texture = material.texture
      		
      		bw = boundingbox.width
      		proj_x = ox*bw
      		proj_y = oy*bw
      		
      		tex_w = (texture.width).inch
      		ratio = bw/tex_w	#calculate the ratio between image dimension and boundingbox dimension,
      							#to preserve same tiling
      
      		pts = []
      		pts[0] = [0, 0, 0]
      		pts[1] = [proj_x, proj_y, 0]
      
      		coords = [pts[0], [0, 0], pts[1], [ratio, 0]]	
      		selected.position_material(material, coords, true)	#here you put the material using new coordinates
      	else
      	UI.messagebox "You must select a face !"
      	end
      end
      
      #------------------------------------------------------------------------------------------------------
      filename="texture_rotator.rb"
      
      if !file_loaded?(filename)
      	plugins_menu = UI.menu("Plugins")
      	if plugins_menu
      		plugins_menu.add_separator
      		plugins_menu.add_item("Rotate texture by angle") {rotate_texture}
      	end
      	file_loaded(filename)
      end
      

      Hope it's helpfull not hellpful πŸ˜›
      regards!

      posted in Developers' Forum
      N
      NewOne
    • RE: Change axes from ruby

      @didier bur said:

      Hi,

      @unknownuser said:

      Is there a posibility to use ruby for this?

      No 😞

      Your answer just cnocked me down 😒
      So the so-easy-to-do right-click command doesn't have any alternative to be executed without user intervention?
      You can see here an example of what I want to do here: http://bayimg.com/aaLjcAabj

      posted in Developers' Forum
      N
      NewOne
    • Change axes from ruby

      Hy ! I want to change a component's axes using a ruby script instead of using the right-click menu "Change Axes" command.
      In particular, what I want is to put the axe's origin in center of the component's boundingbox and rotate the coordonates around Z axis.

      Is there a posibility to use ruby for this?
      Thanks for any help!

      posted in Developers' Forum
      N
      NewOne
    • 1 / 1