sketchucation logo sketchucation
    • Login
    1. Home
    2. fizgig
    3. Posts
    πŸ›£οΈ Road Profile Builder | Generate roads, curbs and pavements easily Download
    F
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 22
    • Posts 69
    • Groups 1

    Posts

    Recent Best Controversial
    • Bug in custom attributes exposed by Ruby...
      1. Make a group and give it a custom attribute "TEST_1" equaling "abc" (value isn't important, the underscore in the var name is...)

      2. Select the group and in the ruby box, type Sketchup.active_model.selection[0].set_attribute("dynamic_attributes","TEST_1","efg")

      3. Now try to delete both custom attributes in the custom attribute dialog box.

      Good luck! I've got some library components where I'm trying to delete these doubled attributes and I haven't figured out how yet. Not even the delete_attribute method appears to help.

      posted in Developers' Forum
      F
      fizgig
    • RE: Trouble with .position_material method

      @thomthom said:

      hm... there is something weird with the UV co-ords the UVhelper returns. That textures is mapped to be stretched almost one time across the face - the UVs to stretch a map across a face once is should not exceed 1.0

      I'm not sure what's going on.

      Yeah, if I understood what the units of the u/v coordinates were, I'd be able to troubleshoot this more.

      posted in Developers' Forum
      F
      fizgig
    • RE: Trouble with .position_material method

      The code was in the first post at the top. I've attached it as a file this time.


      code.rb

      posted in Developers' Forum
      F
      fizgig
    • RE: Trouble with .position_material method

      Can anyone confirm if this is a bug? I'll file it but I'm not sure if it is. I might be doing it wrong.

      posted in Developers' Forum
      F
      fizgig
    • Trouble with .position_material method

      So I mapped a picture onto a face that is a simple rectangle (four vertices). I stretched and pulled it to fit the texture to the face perfectly.

      I then used the UVhelper plugin to get the four points of uv coordinates.

      I then make my own pts matrix with that data and try to reapply the texture using this script:

      pts=[
      							[479.0, 0.0, 95.5],
      							[10.916205, 18.852445, 0.992521],
      							[0.0, 0.0, 95.5],
      							[9.823678, 18.653161, 0.981672],
      							[0.0, 0.0, 0.0],
      							[9.872379, 17.819573, 0.986582],
      							[479.0, 0.0, 0.0],
      							[10.964905, 18.018858, 0.997432]
      							]
      						
      Sketchup.active_model.selection[0].position_material "In_Theatre_Side", pts, true
      

      I've attached the model with the texture applied correctly. I've also attached pictures of before (manually moved texture) and after (texture applied via ruby).

      Anyone know what's going on?

      Texture placed manually...
      before.PNG

      UV Helper tells me what's up...
      uv-helper.PNG

      My Ruby script results...
      after.PNG


      wall.skp

      posted in Developers' Forum
      F
      fizgig
    • RE: Distance between a vertex in one group to a vertex in anothe

      So was my guess accurate? If I want to get the location of a vertex relative to the overall global coordinates, will I have to back-transform out of every group, parent-group and so forth?

      If so, I'm having trouble. When I'm playing around with an edge that's part of a componentinstance which is part of a componentinstance, I can't get the transformation of the componentinstance it is in.

      I do the following command in attempt to make a 3d point object that is located at the starting point of the edge I have selected and back transform it one level:

      Geom;;Point3d.new(Sketchup.active_model.selection[0].start).transform! (Sketchup.active_model.selection[0].parent.transformation)
      

      The trouble is that the parent of this edge is the componentdefintion and not the componentinstance - which makes sense. I just don't know how to get the transformation of the componentinstance that I've currently selected my edge from. My head hurts.

      posted in Developers' Forum
      F
      fizgig
    • RE: Extending ComponentInstance Class

      Understand the concerns. On the way home from work I figured out a way to not have to take this approach but it's good to understand what's going on. Thanks!

      posted in Developers' Forum
      F
      fizgig
    • Extending ComponentInstance Class

      I want to add a new method to the ComponentInstance class. Not sure if it's possible. Here's the basic idea:

      class ComponentInstance
      	def yo
      		UI.messagebox("Tada!")
      	end
      end #class ComponentInstance
      

      I then have try to call the "yo" method on a component instance later and it says the method yo is undeclared.

      Am I missing something?

      posted in Developers' Forum
      F
      fizgig
    • RE: Loading a Material from SKM

      Even better: Found the defintions.load method that will load the model into the list of definitions which then loads the materials.

      posted in Developers' Forum
      F
      fizgig
    • RE: Loading a Material from SKM

      A quick workaround that would work for me is to load a model of a cube or something that has the needed materials mapped to its faces so the materials should load with it.

      The script should load the model and then delete it leaving, hopefully, the materials behind. Trouble is, the Sketchup.active_model.load command requires the user to physically drop the cube into the scene before it can go forward. I'd much rather load it to 0,0,0 or something and then delete it before the user sees it. Anyone know how to do that?

      posted in Developers' Forum
      F
      fizgig
    • Consolidating instances to point at one definition

      I haven't quite tracked down what causes the creation of new definitions in my model. I drag in a component from the file explorer and it inserts into my model just fine. I notice later after inserting more of the same models that I then have a new definition which is the old one plus a "#1" appended to it.

      I know that making a component unique causes that to happen but I haven't done that with my model as near as I can remember. Guess I have two questions:

      1. How could a new definition be made accidentally?
      2. Now that I have a model with some unwanted definitions, can I point the component_instances to reference the original definition that most of my blocks are pointing at and then purge that "#1" definition?
      posted in Newbie Forum sketchup
      F
      fizgig
    • RE: Assign a texture to a group or component instance?

      Thanks Chris!

      Forgot all about the parent class idea. Still wrapping my head around this object-oriented approach. πŸ˜„

      posted in Developers' Forum
      F
      fizgig
    • Assign a texture to a group or component instance?

      I can do it with the built-in ability of sketchup but I don't see a method to do it in Ruby. I'd prefer not to have to go into the sub-entities of a group and color all the items that don't have a material. Is there a trick?

      posted in Developers' Forum
      F
      fizgig
    • RE: Sketchup transformation.to_a structure

      Thanks Jim.

      Time to go learn matrix math!

      posted in Developers' Forum
      F
      fizgig
    • Sketchup transformation.to_a structure

      I can't find documentation anywhere that states what each of the 16 components of the transformation (converted to an array) are. Anyone know?

      posted in Developers' Forum
      F
      fizgig
    • RE: Distance between a vertex in one group to a vertex in anothe

      The rub comes when you want to measure the distance between a vertex inside a group inside a group inside a group to another vertex similarly buried 5 layers deep in another group. You're going to have to back-transform out of every group layer. That's going to be a pain.

      posted in Developers' Forum
      F
      fizgig
    • RE: Distance between a vertex in one group to a vertex in anothe

      TIG, I think you nailed it right on the head. Your post caused me to investigate and learn about the transformation object (fascinating stuff)

      After playing around, I came up with:

      vertex1.position.transform!(group1.transformation).distance vertex2.position.transform!(group2.transformation)
      

      This seems to be about the same thing you suggested. And it works!

      posted in Developers' Forum
      F
      fizgig
    • Distance between a vertex in one group to a vertex in anothe

      Say I draw a rectangle in sketchup.

      I then select one of the four edges of the rectangle and in the ruby window, I make a variable point at it's start vertex:

      vertex1 = Sketchup.active_model.selection[0].start
      

      No sweat. I then put the rectangle into its own group.

      I do the same for another rectangle (but use the variable vertex2 instead while pointing at one of the new rectangle's edges, then I group the 2nd rectangle into its own new group)

      Now, I want to measure the distance between the two vertices:

      vertex1.position.distance vertex2.position
      

      I get an answer. I then move one of the rectangles by moving its group and rerun the distance command above. No change.

      The reason appears to be that the position method returns a vertex with coordinates relative to the local origin of the respective group it's in. I guess I need to somehow get the answer relative to the global origin. Anyone know how to do that?

      posted in Developers' Forum
      F
      fizgig
    • RE: System(iexplorer) freezes sketchup until iexplore is closed

      Thanks for the tip! Will try it out.

      posted in Developers' Forum
      F
      fizgig
    • System(iexplorer) freezes sketchup until iexplore is closed

      I use ruby to make an html file that I want to then show the user. I do it this way:

      system('C;/Program Files/Internet Explorer/iexplore.exe C;/output.html')
      

      I'd like to be able to drag internet explorer to the side so the user can still work with sketchup and keep internet explorer open still viewing the output.html file but sketchup wont listen to any mouse clicks until I close internet explorer. Once I do, I can start messing with the model again but I've lost internet explorer.

      Anyone know how to fix this?

      posted in Developers' Forum
      F
      fizgig
    • 1
    • 2
    • 3
    • 4
    • 3 / 4