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

    Similar Group Finder - Script beginning needs testing

    Scheduled Pinned Locked Moved Developers' Forum
    13 Posts 4 Posters 405 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.
    • thomthomT Offline
      thomthom
      last edited by

      Regarding comparing Face.area - it works fine as long as you give it a little tolerance. (Should be done when comparing all float values.)

      
      # Compare two floats with some tolerance. (Thanks jeff99)
      def self.floats_equal?(float1, float2, epsilon = 0.00000001)
        return ((float1 - float2).abs < epsilon) ? true ; false
      end
      
      

      I'll have a look at this script later. It's interesting. I often get Revit models where identical windows are present, just with different names. Some times the axis points the opposite direction, some times they are identical.

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

      1 Reply Last reply Reply Quote 0
      • Chris FullmerC Offline
        Chris Fullmer
        last edited by

        Thom, when you import a revit file, do the SU group bounding boxes align to the orientation of group? Or do they align to the SU world axes?

        For example, if you import a box, regular flat on the ground box. And a copy of it in revit, but in revit it was rotated in all direction so it is sitting on a single point. In SU, do the boxes axes align to the box or to the model? I had assumed it would align to the model, meaning that I would have to figure out how to re-align their axes on my own.

        But if the axes come in aligned to the box, then that might help immensely.

        Chris

        BTW, anyone have a real life model I could test? Some times simple-ish. Not too simple, but no Taj Mahal πŸ˜„

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

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

          The Revit import only contains Components. Not blocks. And the axis fit the object.

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

          1 Reply Last reply Reply Quote 0
          • Chris FullmerC Offline
            Chris Fullmer
            last edited by

            That's fascinating. They are already components. Do they come in as components and instances where possible then?

            I know autocad brings in blocks as components and instances. So if CAD and Revit do this already, what is the main sue for this script? Groups makers who realize later they want all their groups to be a single component and instance?

            Chris

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

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

              @chris fullmer said:

              That's fascinating. They are already components. Do they come in as components and instances where possible then?

              I know autocad brings in blocks as components and instances. So if CAD and Revit do this already, what is the main sue for this script? Groups makers who realize later they want all their groups to be a single component and instance?

              Chris

              Yea, some come in as instances of each other. But there seem to be some time when they don't. Like when a window is mirrored in Revit, those windows doesn't come in mirrored in SU - but as a component type of their own. Small changes like that.
              That's if you go Revit->DWG->SU

              If you go Revit->FBX->3DS->SU I think all objects comes in a unique objects - all with origin in the model origin.

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

              1 Reply Last reply Reply Quote 0
              • Chris FullmerC Offline
                Chris Fullmer
                last edited by

                Ahh, I see. I'll poke around at the .3ds format and see if it is supporting import of components and instances at all. I kind of doubt that it is.

                Chris

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

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

                  @chris fullmer said:

                  Ahh, I see. I'll poke around at the .3ds format and see if it is supporting import of components and instances at all. I kind of doubt that it is.

                  Chris

                  It does.

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

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

                    Though, it has had issues - not sure if they have been fixed. http://forums.sketchucation.com/viewtopic.php?f=11&t=12272

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

                    1 Reply Last reply Reply Quote 0
                    • RunnerPackR Offline
                      RunnerPack
                      last edited by

                      This is a very cool idea for a plug-in! I've thought of it myself, of course (most people who've worked with SU for very long probably have) but then thought of how hard it would be to write (and how slow it would probably run on my ancient PC πŸ˜‰ ).

                      But, I'm very glad to see the gauntlet has been taken up - especially by someone as talented at plug-in writing as Chris F. πŸ˜„

                      I have been studying the transformations of Groups and the geometry inside for a plug-in I'm making, so I may have something to add to this in later stages (though I'm terrible at math).

                      Thom:

                      Not to criticize your coding style or Ruby skills (or those of "jeff99"), but I thought I'd point out that, in Ruby, both the "return" statement and the trinary conditional are technically superfluous, in this case.

                      Since the condition itself evaluates to either 'true' or 'false', and since Ruby returns the value of the last statement as the method's value, the entire contents of the method could be simply:

                      # Compare two floats with some tolerance. (Thanks jeff99 and thomthom)
                      def self.floats_equal?(float1, float2, epsilon = 0.00000001)
                        ((float1 - float2).abs < epsilon)
                      end
                      

                      (One could also make it easier to use by overriding the === [triple equals] method for floats, but I don't know what the consequences of this would be. Maybe a '====' method, instead?)

                      I don't know what impact, if any, this would have on the speed of a plug-in, but one like Chris' would be doing a lot of these...

                      Also, is that a loose enough tolerance for this usage? I suppose it would depend on the scale and level-of-detail of each model.

                      Well, I'll stop wasting everyone's time now πŸ˜†

                      You might have noticed... I'm a bit of a ferpectionist.

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

                        @runnerpack said:

                        Not to criticize your coding style or Ruby skills (or those of "jeff99"), but I thought I'd point out that, in Ruby, both the "return" statement and the trinary conditional are technically superfluous, in this case.

                        hm.. good point about the trinary - not sure why it's even there.

                        As for the return keyword - I prefer to use them as I read my code better when I see an explicit return statement. All though for such a short method it could be skipped, but you know old habits and all.
                        But thanks for mentioning it. Since I picked up Ruby I've changed my coding style a few times as I've learned more about the language.

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

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

                          @runnerpack said:

                          (One could also make it easier to use by overriding the === [triple equals] method for floats, but I don't know what the consequences of this would be. Maybe a '====' method, instead?)

                          Seeing how there's so many that develop plugin for Sketchup, I'm avoiding extending base classes to avoid potential conflicts. Had it been in a isolated environment where only I coded I'd extend them. (I often want to, but I play it safe.)

                          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

                            I use...

                            class Float
                            	def =~(num2,tol=10000)
                            		num1=(self*tol).to_i
                            		num2=(num2*tol).to_i
                            		return true if num1==num2
                            		return nil
                            	end
                            end #class Float
                            

                            TIG

                            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