sketchucation logo sketchucation
    • Login
    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!
    🛣️ Road Profile Builder | Generate roads, curbs and pavements easily Download

    Incorrect radius value.

    Scheduled Pinned Locked Moved Plugins
    4 Posts 3 Posters 262 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.
    • A Offline
      Antondeg
      last edited by

      I create an arc with a Radius of 5M on my drawing. Then when I read that value through Ruby I get either a value of 196 or 180 and I am not sure of the units. The length is also wrong. I find the edge then I get the curve off the edge then I get the radius from the curve.

      
      entity.curve.radius.to_s
      
      

      Any ideas how to get the correct value?

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        All angles from SketchUp is in radians.
        All lengths are in inches - and comes as a Length object (subclass of Float)

        There are helper methods to deal with this:

        Use .radians and .degree to convert between angle and radians.
        http://code.google.com/apis/sketchup/docs/ourdoc/numeric.html#radians
        puts entity.curve.angle.radians.to_s

        When you have a Length and want to display it to the user, just rely on Length.to_s to present the length in the model units.
        http://code.google.com/apis/sketchup/docs/ourdoc/length.html
        puts entity.curve.radius.to_s

        Make sure you know if you have a Float or a Length object - make use of the Length class, don't try to convert between other units unless you need to present anything to the user. Remember that a Length converted to float returns the length in inches as that is the system unit for SketchUp.

        Thomas Thomassen — SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

        1 Reply Last reply Reply Quote 0
        • TIGT Offline
          TIG Moderator
          last edited by

          @antondeg said:

          I create an arc with a Radius of 5M on my drawing. Then when I read that value through Ruby I get either a value of 196 or 180 and I am not sure of the units. The length is also wrong. I find the edge then I get the curve off the edge then I get the radius from the curve.

          entity.curve.radius.to_s
          

          Any ideas how to get the correct value?

          How are you setting the radius to "5m" ?
          You must use 5.m or equivalent?
          When you get the radius in code it's in inches so entity.curve.radius.to_m.to_s will return a string with it in meters.
          In Entity Info it shows in 'current units'.
          The 'length' of an arc given in Entity Info [or code] is the accumulative length of the arc's individual segments in current units - the more segments an arc has the nearer it is to the real length of a 'true' arc.
          To calculate the true length of an arc find it's swept_angle=end_angle-start_angle [which is automatically in radians] and then use
          length = 2*Math::PI*radius*swept_angle/(2*Math::PI) = radius*swept_angle in inches
          If it's a circle [i.e. edge.curve.is_polygon?] then use
          length = 2*Math::PI*radius
          TIP: to check if a Curve is an Arc, and therefore it can have a radius use
          edge.curve.typename=="ArcCurve"

          TIG

          1 Reply Last reply Reply Quote 0
          • A Offline
            Antondeg
            last edited by

            Thanks once I used to_m I got the correct value.

            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