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

[Plugin]ArcCurve-set_segments.rb & changearcsegments 130830

Scheduled Pinned Locked Moved Plugins
32 Posts 11 Posters 65.0k Views
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.
  • T Offline
    TIG Moderator
    last edited by TIG 22 May 2009, 15:02

    ArcCurve-set_segments.rb

    (c) TIG 2009-2013

    Adds new method to ArcCurve to change number of segments -

    like in the Entity Info dialog...

    Usage: arc.count_edges >>> 12

    arc.set_segments= 36

    arc.count_edges >>> 36

    It will NOT work on arcs with attached face(s) that are NOT 'coplanar' -

    either with the arc or with each other.

    Connected faces with orientation, materials, holes etc are retained.

    20090522 First issue.

    20090928 Added the ArcCurveTests, remakes Arc, Circle or Ngon.

    20091002 ArcCurveTests improved.

    20110216 Clashes with other methods fixed.

    20120121 Put inside TIG module and Plugins menu item added.

    TIG.changearcsegments NNN

    changes all arcs/circles in selection to be NNN sided

    e.g. to smooth selected arcs in an imported dxf plan...

    large selections with many segments might take a while to run...

    Usage: In the Ruby Console type TIG.changearcsegments 64

    All Arcs/Circles within the current Selection will now have 64 sides...

    OR use Plugins menu item and enter number in the dialog...PayPalButton Download the latest RBZ version from the SCF PluginStore http://sketchucation.com/resources/pluginstore?pln=ArcCurve_set_segments or through the SketchUcation Plugin Store toolset from within SketchUp itself...

    TIG

    1 Reply Last reply Reply Quote 0
    • C Offline
      Chris Fullmer
      last edited by 22 May 2009, 16:16

      TIG! That's great! This has been sorely needed in the API. I've already forgotten all the scripts that have been requested that needed this feature. Thanks soo much for this one!

      Chris

      Lately you've been tan, suspicious for the winter.
      All my Plugins I've written

      1 Reply Last reply Reply Quote 0
      • G Offline
        gavvy
        last edited by 23 May 2009, 07:16

        😞
        I ADD THESE TO IT

        #def changearcsegments(segments)
        def changearcsegments
        model=Sketchup.active_model
        name="Change Arc Segments"

        ##================
        $ff_edges = 1 if not $ff_edges
        prompts = ["Change Arc Segments: "]
        value = [$ff_edges]
        result = inputbox prompts, value, "Change Arc Segments"
        return if not result
        $ff_edges = result[0]

        segments=$ff_edges

        ##================
        if Sketchup.version.split('.')[0].to_i >= 7

        1 Reply Last reply Reply Quote 0
        • T Offline
          TIG Moderator
          last edited by 23 May 2009, 09:21

          That's fine - it's code that's to be used freely - please just credit me where credit is due and don't sell it. πŸ˜„

          Incidentally, I'd use @ff_edges [which sets it for that session for that script], rather than $ff_edges [which sets it globally for all loaded scripts that session and could clash if someone else has used it ! ]

          Why not also add some more code to make it a Plugins-Menu item or better a right-click Context-Menu item that gets shown only if the current selection contains an ArcCurve - a bit like the arc_center_point ruby?

          I was just demonstrating a possible use for the new method - you can puzzle over it and add any fripperies you like... πŸ€“

          Post your version when you're done - I suggest you call it something a little different to avoid script clashes...

          TIG

          1 Reply Last reply Reply Quote 0
          • P Offline
            pilou
            last edited by 25 May 2009, 00:31

            @ TIG: Cool Now with the Console I will be try this tricky code! β˜€
            Or maybe I am optimistic and some more code must be written ? The console use + code above are sufficient?
            The plug is "stand alone"?

            Edit: I Try the Console: works fine 😎
            And works also for the circles! 😲
            Bravo! πŸ‘

            Frenchy Pilou
            Is beautiful that please without concept!
            My Little site :)

            1 Reply Last reply Reply Quote 0
            • G Offline
              gavvy
              last edited by 25 May 2009, 02:44

              😲
              TIG
              The script I add just copy from the projectnormalface.rb.
              I try the @ff_edges it work well πŸ˜›
              Incidentally, i call scripts through the usertoolbar written by Jim ,so the ruby files i use no menu or button script (i delete them 😲 )

              1 Reply Last reply Reply Quote 0
              • P Offline
                pilou
                last edited by 25 May 2009, 17:39

                For the volumes 3D from Autocad does it possible to make the same thing?

                Something like this in the Widows box option of SU importation : give minimum angle between facets
                (so numbers of segments of arcs will be limited by this value)
                But I don't know how is managed entities 😳
                I suppose 2 circles connected but... πŸ˜’

                here a cylinder from autocad


                cylinder.zip

                Frenchy Pilou
                Is beautiful that please without concept!
                My Little site :)

                1 Reply Last reply Reply Quote 0
                • T Offline
                  TIG Moderator
                  last edited by 25 May 2009, 21:24

                  Unfortunately SUp doesn't allow [easy] editing of many of the properties of arcs or circles it they form parts of complex 3D shapes... Changing an arc or circle could change so many other things that are connected to it that it would quickly become unmanageable ! So, you cannot change the number of segments in an arc or circle using Entity Info IF it has connected faces that aren't coplanar with the arc/circle itself... My new 'method' has the same limitations...

                  Sorry...

                  TIG

                  1 Reply Last reply Reply Quote 0
                  • P Offline
                    pilou
                    last edited by 25 May 2009, 21:43

                    Well, Nevemind! πŸ˜‰
                    Maybe something to make by "exploding" object in Autocad πŸ˜’

                    Frenchy Pilou
                    Is beautiful that please without concept!
                    My Little site :)

                    1 Reply Last reply Reply Quote 0
                    • P Offline
                      pilou
                      last edited by 1 Jun 2009, 21:26

                      All this don't arrive if you use Moi πŸ˜‰
                      Here a simple cylinder with a hight number of segments πŸ˜„
                      (limit of the 24 segments default is overpassed πŸ˜‰
                      And you can control the aspect of polygons before exportation!
                      Exportation is in SKP format of course! β˜€

                      http://forums.sketchucation.com/download/file.php?id=28152

                      Frenchy Pilou
                      Is beautiful that please without concept!
                      My Little site :)

                      1 Reply Last reply Reply Quote 0
                      • C Offline
                        Chris Fullmer
                        last edited by 1 Jun 2009, 23:20

                        That is one of the key differences of solid modeler vs. face modeler.

                        Lately you've been tan, suspicious for the winter.
                        All my Plugins I've written

                        1 Reply Last reply Reply Quote 0
                        • T Offline
                          TIG Moderator
                          last edited by 28 Sept 2009, 09:04

                          Here is an updated version http://forums.sketchucation.com/viewtopic.php?p=158903#p158903
                          e.g. arcCurve.set_segments=6

                          You will need both of the rubies that are attached there...

                          The new file, ArcCurveTests.rb, includes three new methods is_loop?, .is_circle? and .is_polygon? - these methods are not accessible through Ruby otherwise...

                          They are used to determine the original ArcCurve's underlying 'type' [Arc/Circle/Polygon] and then use that to remake the geometry with the new segment/sides count as the right 'type' [previously any Circles/Polygons that were changed by this method became 'Arcs' !]...

                          EDIT: ArcCurveTests.rb updated... 20091002

                          TIG

                          1 Reply Last reply Reply Quote 0
                          • thomthomT Offline
                            thomthom
                            last edited by 19 May 2010, 07:54

                            Some of these methods can be simplified with the aid of Curve.is_polygon? added in Google SketchUp 7.1 - Maintenance 1.

                            Here's a set I made for my TT_Lib:

                            
                            	def self.is_curve?(entity)
                            		return false unless entity.is_a?(Sketchup;;Edge) && entity.curve
                            		return false if entity.curve.respond_to?(;is_polygon? ) && entity.curve.is_polygon?
                            		return true
                            	end
                            	
                            	def self.is_arc?(entity)
                            		return self.is_curve?(entity) && entity.curve.is_a?(Sketchup;;ArcCurve)
                            	end
                            	
                            	def self.is_circle?(ent)
                            		# (i) A bug in SU makes extruded circles into Arcs with .end_angle of 720 degrees when reopening the file.
                            		# Instead of checking for 360 degrees exactly, we check for anything larger as well. A 2D arc
                            		# can't have more than 360 degrees.
                            		#
                            		# This doesn't work. Maybe due to rounding errors?
                            		# return (arc_curve.end_angle - arc_curve.start_angle >= 360.degrees) ? true ; false
                            		return false unless self.is_arc?(ent)
                            		return ((ent.curve.end_angle - ent.curve.start_angle).radians >= 360) ? true ; false
                            	end
                            	
                            	def self.is_polygon?(ent)
                            		return ent.is_a?(Sketchup;;Edge) && ent.curve && ent.curve.respond_to?(;is_polygon? ) && ent.curve.is_polygon?
                            	end
                            	
                            	def self.is_ngon?(ent)
                            		return false unless self.is_polygon?(ent) && ent.curve.is_a?(Sketchup;;ArcCurve)
                            		return ((ent.curve.end_angle - ent.curve.start_angle).radians >= 360) ? true ; false
                            	end
                            
                            

                            SU versions prior to this .is_polygon? will not be able to tell a Circle or Polygon apart, but no error is thrown.

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

                            1 Reply Last reply Reply Quote 0
                            • T Offline
                              TIG Moderator
                              last edited by 16 Feb 2011, 22:22

                              Here's an updated version that avoids other method clashes... http://forums.sketchucation.com/viewtopic.php?p=158903#p158903
                              IF you have the older script ArcCurveTests.rb installed please remove it as it might clash with some other methods...

                              TIG

                              1 Reply Last reply Reply Quote 0
                              • E Offline
                                eskis
                                last edited by 6 Aug 2011, 23:08

                                great! great! great! that is what i was looking for!!!!!!
                                thank you...

                                1 Reply Last reply Reply Quote 0
                                • A Offline
                                  ahnvtk
                                  last edited by 23 Aug 2011, 17:05

                                  I've tried making a script that automatically creates an 8-sided circle in a group at sketchup start, to see if all circles created by a user would then be 8-sided as well. They aren't - scripting an 8-sided circle still leaves the default sides at 24. 😞

                                  I tried changing the sides of a circle with this script as well - Sketchup still leaves the default at 24.

                                  How can I change the default sides of a circle? ❓

                                  1 Reply Last reply Reply Quote 0
                                  • T Offline
                                    TIG Moderator
                                    last edited by 23 Aug 2011, 19:28

                                    You can't.
                                    😞

                                    TIG

                                    1 Reply Last reply Reply Quote 0
                                    • A Offline
                                      ahnvtk
                                      last edited by 23 Aug 2011, 21:26

                                      😞

                                      At least this script here just saved me time reducing polys from extruded circles.. thanks!

                                      1 Reply Last reply Reply Quote 0
                                      • B Offline
                                        boilingsnow
                                        last edited by 20 Jan 2012, 23:16

                                        TIG it's nice of you to share this with us. I think this ruby is very useful but it's convenient to use because everytime I have to type "changearcsegments NNN" in the ruby console...Why not make it possible to be added in the plugin menu and works with a popup window to type in the segment number.

                                        1 Reply Last reply Reply Quote 0
                                        • T Offline
                                          TIG Moderator
                                          last edited by 21 Jan 2012, 11:45

                                          Edit the script with a plain-text editor [Notepad/Notepad++.exe] and add this code at the end

                                          unless file_loaded?(File.basename(__FILE__))
                                            UI.menu("Plugins").add_item("Change Arc Segments"){
                                              segments=inputbox(["Segments; "],[12],"Change Arc Segments")
                                              changearcsegments(segments[0])if segments
                                            }
                                          end
                                          file_loaded(File.basename(__FILE__))
                                          

                                          TIG

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

                                          Advertisement