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

    Posts

    Recent Best Controversial
    • RE: Get coordinates of nested components

      @fredo thanks for your reply...

      So if I understand what you're saying, I need to find all the nested parent components first and there location and from there iterate the nested child components of each nested parent component to get the cumulative location?

      Sorry I think I even confused myself! πŸ˜•

      posted in Developers' Forum
      F
      Frankn
    • Get coordinates of nested components

      As the title says... I want to get the coordinates of all nested components.

      I've searched but admittedly I don't really understand how transformations work so I might not be searching correctly.

      When iterating a component I can get the origin of each nested component but that only returns the coordinates relative to it's immediate parent but not relative to the whole component tree... if that makes sense.

      I'm assuming I would have to add each relative component transformation but I have no idea how to do that.

      posted in Developers' Forum
      F
      Frankn
    • How to replicate change axes

      Is there a way to change the axes of a component instance like you would by right clicking and selecting change axes?

      I've searched but haven't found anything, I tried applying a transformations and nothing works!

      Thanks

      posted in Developers' Forum
      F
      Frankn
    • RE: Best practices for creating an rbe

      Where can I find info and/or examples on how to set this part of the loader file? I'm searching but not finding anything...

      require "Author_MultiClassPlugin/MultiClassPlugin_SharedConstants.rb"
      
      include SharedConstants # mixin the constant module
      

      And this from the SharedConstants file?

      SOME_SEARCH_PATTERN ||= /^Author/
      

      Thanks

      posted in Developers' Forum
      F
      Frankn
    • RE: Best practices for creating an rbe

      Thanks for the info Dan... I'll check out those forums. I wasn't even aware that the Sketchup API had it's own require method and it explains why I'm having problems. I guess I have some more learning and reading to do! πŸ˜„

      posted in Developers' Forum
      F
      Frankn
    • Best practices for creating an rbe

      I've been trying to get a plugin signed and running into some issues which seem to be related with require... I get these errors...
      @unknownuser said:

      Error: #<LoadError: cannot load such file
      .

      I found this post https://forums.sketchup.com/t/cant-load-required-rb/42755/3 where Dan uploaded some templates but I'm not sure how the
      @unknownuser said:

      MultiClass_MultiFile.zip
      works. Does anyone have a sample code that I can look at or can someone please explain how those files should be structured and how they work together?

      Frank

      posted in Developers' Forum
      F
      Frankn
    • RE: Win32API is deprecated after Ruby 1.9.1

      Thanks for the info Dan... I didn't check to see if there's a difference when loading different versions, just haven't had time and other than being annoying I don't see any problems in my plugin.

      When I get a chance I'll look into it more and see if there are other errors as you suggested.

      posted in Developers' Forum
      F
      Frankn
    • Win32API is deprecated after Ruby 1.9.1

      I'm getting this error
      @unknownuser said:

      C:/Program Files/SketchUp/SketchUp 2021/Tools/extensions.rb:197: warning: Win32API is deprecated after Ruby 1.9.1; use fiddle directly instead

      My plugin was working before today and I haven't changed anything, what can be causing this error all of a sudden?

      Thanks

      posted in Developers' Forum
      F
      Frankn
    • RE: Moving a curved face/surface

      Found this post which helped me find the solution...
      https://forums.sketchup.com/t/transform-a-model-vertex-by-vertex/38771/7

      Here's the code I'm using with some notes... if something can be improved or changed please let me know? I can also add the code to iterate the faces if needed?

      Basically you need the vertices of all the faces you want to move and each vertex needs a cooresponding vector to be moved to. That way you can pass the 2 arrays to

      transform_by_vectors(vertices, vectors)
      

      . Andif you're using sub components like I am, make sure you're in the correct entities context (not sure I'm using all the proper terminology here) oe else you get a mess as a result.

      Like Tig explained in the post I shared...

      @unknownuser said:

      ... if every vector has a separate vector-transformation you need to pass two full arrays - in one go!

                      
      vectors=[]  //array of position to move vertices
      vertices=[] //array of face vertices from the individual faces that make up the surface
      
      vertices.flatten!  //in my case I need to flatten the array
      vertices.uniq!     //make sure there are no duplicate vertex
      
      vertices.each{|vector|
        position=vector.position.clone    
        position.x +=distance
        vectors.push vector.position.vector_to(position)
      }
                                      
      component_entity.transform_by_vectors(vertices, vectors)
      
      

      Hopefully this helps others out because it wasn't easy to find or understand... but it works!

      posted in Developers' Forum
      F
      Frankn
    • Moving a curved face/surface

      As the title says, how do I move the curved face/surface? I'm able to iterate and get the individual faces and I tried

      face[0].pushpull distance
      

      within the loop but the faces take off in different directions.

      I tried

      face[0].transform!(Geom;;Transformation.new([0, distance, 0]))
      

      but that doesn't work.

      I also tried adding the faces to selection and doing something with that but I can't get anything to work.

      Thanks...

      curved face.jpg

      posted in Developers' Forum
      F
      Frankn
    • RE: Undoing all transformations

      Thanks for all that info fredo... It'll certainly come in handy

      posted in Developers' Forum
      F
      Frankn
    • RE: Undoing all transformations

      sdmitch, just had a chance to try it out and it does work...

      Thanks!

      posted in Developers' Forum
      F
      Frankn
    • Undoing all transformations

      I'm pretty sure I've seen this before but I can't find the answer... so sorry in advanced if this is a repeat question.

      I'd like to remove all transformation for a given instance... so basically reverse what ever moves and rotations were done.

      I can get the transformation array,

      e.transformation.to_a
      

      and i tried setting everything back to 0 bu that didn't work...

      Thanks

      posted in Developers' Forum
      F
      Frankn
    • RE: Ruby not returning correct dimensions

      Thanks for the reply and clarification Tig!

      The issue I'm having is that I'm using group_by to group by thickness but since the values don't match group_by doesn't work. So knowing what you just explained I'm using 0.4999999999999716.round(6) and that seems to do the trick. I use (6) because some values in inches have six digits after the .

      If there's another way fix this issue please let me know.

      posted in Developers' Forum
      F
      Frankn
    • Ruby not returning correct dimensions

      Sorry in advance for what may be a really noob question and I know I've seen this before but been away from scripting for a while and can't remember and can't find the solution by searching...

      Basically if I have 3 components in my model each being 1/2" thick when I retrieve the components dimensions in ruby, 2 of them return 0.5 and one returns 0.4999999999999716. Why? and how do my fix that? I did try adding .to_l in my code but that didn't help.

      Thanks

      posted in Developers' Forum
      F
      Frankn
    • Move component diagonally and rotate

      As the title says... I'm trying to move and rotate a component while centering it within the angled face of the other component. Both are subcomponents if that matters.

      Here's a pic to illustrate what I'm trying to do...


      comp move diag.jpg

      posted in Developers' Forum
      F
      Frankn
    • Working with millimeters

      Hi everyone,

      I'm working on a cabinet pluggin and would like to add support for mm but never work in metric.... so I'd like some feedback for those who work with mm, how precise do you get?

      Here's an example... in imperial 4 1/16in = 103.1875mm in metric. Would 103.1875mm be rounded off to 103, 103.19, 103.2 or not rounded at all?

      Thanks,
      Frank

      posted in Woodworking
      F
      Frankn
    • Getting angle relative to component

      I'm using the following code to get the angle relative to the world axis and it works great but I'd also like to get the angle relative to the component which is selected when the cursor is inline with the component... like in the attachement where the angle read is 45 returned is 45 degrees I'd like it to be 0.0 degrees.

      
       @rotation_point=Geom;;Point3d.new(@iptemp.position)		    
       ptx=Geom;;Point3d.new(@ip2.position)
       ptx=Geom;;Point3d.new([ptx.x, ptx.y, @rotation_point.z]) 
       vector=@rotation_point.vector_to(ptx) 				
       crossvector=vector.cross(X_AXIS)
       multiplier=crossvector[2]
      		    
       if multiplier<0
         multiplier=1
       else
         multiplier=-1
       end 
      		    
       @angle=((X_AXIS.angle_between(vector)).radians)*multiplier
      
      

      I tried getting the component's angle and subtracting it from @angle but the results aren't very accurate for some reason. I also tried creating a new vector3d from the compoent instance's transformation and that gives me the same results

      			
       trans=parent_instance.transformation.to_a
       vector=Geom;;Vector3d.new(trans[0], trans[4], trans[8])
      
      

      angle ex.jpg

      Any ideas?

      EDIT: Found a solution
      Actually had the solution all along but it was so simple I overlooked it...
      subtracting the existing components angle from @angle does work... IF you do it in the right order!! 😳

      wrong...

       existing_comp_angle-@angle 
      

      right...

       @angle-existing_comp_angle 
      
      posted in Developers' Forum
      F
      Frankn
    • RE: Retrieving bounding box corners Point3d

      @thomthom said:

      The BoundingBox object you get when you query the instance will always be oriented to world space. To get the bounding box as drawn in the UI you need to get the bounds of the definition - fetch all the points from its corners and transform them using the current edit_transform and the selected instance transform. That extension I linked to does all that.

      Ah! Thanks for the explaination ThomThom! I didn't realise that's what happened with instances' bounding boxes...very confusing for a novice!

      I did take the time to check out your extension and was able to understand what you're doing and apply that to my own code... thanks again sir!

      posted in Developers' Forum
      F
      Frankn
    • RE: Retrieving bounding box corners Point3d

      Thanks sdmitch that did the trick!

      Thanks also tt_su for the code I'll def take a look at it but I'm able to draw the box except that it won't follow the orientation of the component. Is there a way to rotate the bbox once created?

      bbox.jpg

      Here's the code I'm using to create the bbox... credit needs to be given to Fredo that's where I got the code snipet.

      
      bounding_box_corners=@boundingbox_lines.collect{|i| @main_module.bbox_point3d[i]}
      view.draw_lines(bounding_box_corners)
      
      

      @boundingbox_lines=[0, 1, 1, 3, 3, 2, 2, 0, 4, 5, 5, 7, 7, 6, 6, 4, 0, 4, 1, 5, 2, 6, 3, 7]

      ie of @main_module.bbox_point3d...
      @main_module.bbox_point3d [Point3d(0, 0, 0), Point3d(22, 0, 0), Point3d(0, 22, 0), Point3d(22, 22, 0), Point3d(0, 0, 22), Point3d(22, 0, 22), Point3d(0, 22, 22), Point3d(22, 22, 22)]

      posted in Developers' Forum
      F
      Frankn
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 1 / 6