sketchucation logo sketchucation
    • Login
    šŸ¤‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Help with .followme

    Scheduled Pinned Locked Moved Developers' Forum
    7 Posts 3 Posters 177 Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D Offline
      dacastror
      last edited by

      Hi guys, I am making a plugin where I need to use .followme and I'm having bug splat with some curves, an attached two example curves that give me problems
      curves
      here a fragment of my code

      model = Sketchup.active_model
      sel = model.selection
      ent = model.entities
      selec = []
      selec.clear
      sel.each{|ob| selec.push(ob) if ob.is_a?(Sketchup;;Edge)}
      if selec.size == 0
         UI.messagebox "Please select a Curve"
         return
      end
      
      radio_tubo = 10.0.cm
      lados_tubo = 8
      pts=[]
      pts.clear
      pts=selec[0].vertices.collect{|v| v.position} 
      
      
      if Sketchup.version.to_f < 7.0
         model.start_operation("Draw tube")
      else
         model.start_operation("Draw tube", true)
      end
         grupo = ent.add_group
         entities = grupo.entities
         normal_cir = (pts[0].vector_to pts[1]).normalize
         circle = entities.add_circle pts[0], normal_cir, radio_tubo, lados_tubo
         cara = entities.add_face circle
         cara.reverse!.followme selec
         #selec.each{|edge| edge.erase!}
      model.commit_operation
      
      qq="OK"
      

      I try to test the plugin TubeAlongPath.rb with radius = 10 cm and also the bug occurs
      plugin
      I've noticed that with smaller r no problem (for example r = 2 cm)

      I do not know how to fix this, in advance thank you for your help

      (google translator)

      .

      1 Reply Last reply Reply Quote 0
      • Dan RathbunD Offline
        Dan Rathbun
        last edited by

        entities.add_circle does NOT return a Sketchup::Curve object.
        It returns an Array of Sketchup::Edge objects, that make up the curve.

        So line 27 should be:
        edges = entities.add_circle( pts[0], normal_cir, radio_tubo, lados_tubo )

        ... and line 28:
        cara = entities.add_face( edges[0].curve )

        I'm not here much anymore.

        1 Reply Last reply Reply Quote 0
        • D Offline
          dacastror
          last edited by

          Thanks Dan, I modified my code.
          My problem persists, someone can see the problem?

          1 Reply Last reply Reply Quote 0
          • sdmitchS Offline
            sdmitch
            last edited by

            Your problem in not so much your code but the curve itself, 320x0.42cm segments. Reducing the number of segments or scaling the curve up 100x worked without Bug Splat. Also reducing the circle size to 1cm worked as well. The 10cm circle is just to big for the curve.

            Nothing is worthless, it can always be used as a bad example.

            http://sdmitch.blogspot.com/

            1 Reply Last reply Reply Quote 0
            • D Offline
              dacastror
              last edited by

              Thanks for the reply sdmitch, give me a first clue
              what worries me is that the user of the plugin do this and generate a bug splat on, I would like in this case simply do not tube, but do not understand how to calculate the minimum length allowed for this case

              1 Reply Last reply Reply Quote 0
              • sdmitchS Offline
                sdmitch
                last edited by

                It is probably more a function of the angle between segments than the length of the segments. In this case, the maximum radius is something between 4 and 5cm.

                Nothing is worthless, it can always be used as a bad example.

                http://sdmitch.blogspot.com/

                1 Reply Last reply Reply Quote 0
                • D Offline
                  dacastror
                  last edited by

                  you sent me on the right track, thanks sdmitch

                  1 Reply Last reply Reply Quote 0
                  • 1 / 1
                  • First post
                    Last post
                  Buy SketchPlus
                  Buy SUbD
                  Buy WrapR
                  Buy eBook
                  Buy Modelur
                  Buy Vertex Tools
                  Buy SketchCuisine
                  Buy FormFonts

                  Advertisement