sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Getting the "circle steps" ???

    Scheduled Pinned Locked Moved Developers' Forum
    11 Posts 4 Posters 205 Views 4 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.
    • K Offline
      ksor
      last edited by

      Now I need to get the "steps" a circle is build of (standard is 24) but it can be changed dirung a session and then resets to 24 again when SU is restarted.

      How can I "get" this "step" as a number and use it in my code ?

      Best regards
      KSor, Denmark
      Skype: keldsor

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

        A circle is a Sketchup::ArcCurve instance.

        All classes in Ruby inherit methods from their superclass (and it's superclass, and the superclass of that, .. and so on, back to Object [which has module Kernel, mixed into it.])

        So ...

        Sketchup::ArcCurve.superclass %(#008000)[>> Sketchup::Curve]

        Looking at the API for Sketchup::Curve, we find:

        count_edges()

        I'm not here much anymore.

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

          By the Way.. the actual default is hard-coded and cannot be changed by the user (manually, or easily by code.)
          This is one of the common feature requests that SketchUp does not yet have.

          The "current" value of Curve segments is kept internally by SketchUp.. and is not yet exposed via the Ruby API. (Nor is it saved in the defaults in the Registry/Plist.)
          Access to it is one of the API feature requests that has been logged.

          I'm not here much anymore.

          1 Reply Last reply Reply Quote 0
          • K Offline
            ksor
            last edited by

            Argh ... thx anyway Dan !

            Best regards
            KSor, Denmark
            Skype: keldsor

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

              You can of course change the segments of an Arc/Circle, in code as you make it.

              I recall someone once wrote a PC only script that auto-loaded and ran as Sketchup started [you could also use an observer to ensure the setting applied to new SKP files in that session].
              It ran some winscript shortcut=C] to make a circle inside a temp-group and did various key-strokes for segments/radius/etc [36s/1 etc] - then it immediately erased the circle-temp-group.
              The new segment number is then used that session for all new circles...

              TIG

              1 Reply Last reply Reply Quote 0
              • M Offline
                Michaelv
                last edited by

                Is there a way to batch change in a script?

                I.e. I run a script and the first action is to change all arcs and circle to a number of segment such that each segment is smaller than xxx.

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

                  Yup.. that's what I meant by "not easily."

                  I'm not here much anymore.

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

                    @michaelv said:

                    Is there a way to batch change in a script?

                    I.e. I run a script and the first action is to change all arcs and circle to a number of segment such that each segment is smaller than xxx.

                    You may be able to iterate the Curve's edges ( curve.edges.each ) and split each one at it's midpoint ( edge.split ) .. don't know. I never tried it.

                    Otherwise, .. you would have to recreate them I think. Get each one's start point, end point, center, angle, and make a new one to replace it. Delete the old one.

                    I'm not here much anymore.

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

                      Just tried it at the console. It does indeed split each edge. BUT ... the new vertices remain at the center of the chords. (They do not move out to the circumference, like they do if you use the native "DivideTool.")

                      And I do not see an API method equivalent for that tool.

                      I'm not here much anymore.

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

                        My "ArcCurve-set_segments" tool lets you change the segments of selected Arcs, just as you could using Enity Info on each one... you are also bound by the same limitations - e.g. you can't change the segments if the Arc is part of a 3d object...
                        e.g. In the Ruby Console typing
                        changearcsegments 360
                        makes selected [eligible] Circles have 360 segments...

                        TIG

                        1 Reply Last reply Reply Quote 0
                        • M Offline
                          Michaelv
                          last edited by

                          @tig said:

                          My "ArcCurve-set_segments" tool lets you change the segments of selected Arcs, just as you could using Enity Info on each one... you are also bound by the same limitations - e.g. you can't change the segments if the Arc is part of a 3d object...

                          Argh, that's exactly what I was envisioning to do (a 3D object application). Well it makes sense that it cannot be done on the volume by changing the segments of the generating geometry. I didn't think of that.

                          Thanks for the answers.

                          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