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

    Custom importer - setting options

    Scheduled Pinned Locked Moved Developers' Forum
    11 Posts 3 Posters 489 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.
    • T Offline
      tireddude
      last edited by

      Hi. I'm writing a custom KMZ importer mainly because SU's built in KMZ importer/exporter won't read/write the KML <orientation></orientation> tag for tilt, roll and heading angles causing KMZ import-export operations to make models "misplaced" in Google Earth. However, that is really not what this post is about. Please read on.

      My custom importer is doing this (among other things)

      class AcustomImporter < Sketchup;;Importer
      

      but i'm having troubles setting options. I need to be able to set "Validate Kmz file" and "Merge Coplanar Faces" option from code. When i use my custom importer, it is reading whatever values the user last set in the options dialog for Google Earth Files importer!

      I also found out that these options are read by SketchUp from the windows registry upon SU startup and loaded into some (at least to me) hidden variable. Key is HKEY_CURRENT_USER\Software\SketchUp\SketchUp 2014\Kmz Importer. When the user changes options, the new values are written immediately to the Windows Registry. If i try to change in the registry and open the options dialog again, values are NOT updated there.

      How can i access these options from code? And why are they affecting my custom importer? Can't find anything in the API for this. It is like

      Sketchup.active_model.import filePath , showSummary
      

      should have a few more arguments.

      Any help on this matter would be much appreciated.

      (Related to Sketchup Make 2014)


      Want to manipulate these options from code.

      1 Reply Last reply Reply Quote 0
      • tt_suT Offline
        tt_su
        last edited by

        You made an importer from scratch? In which case I don't see why the SU settings should affect your code. I'd be hard to say what is going on without seeing your code though.

        1 Reply Last reply Reply Quote 0
        • tt_suT Offline
          tt_su
          last edited by

          Oh... hang on. Is your importer calling The Ruby API Model.import method?

          1 Reply Last reply Reply Quote 0
          • T Offline
            tireddude
            last edited by

            @tt_su said:

            Oh... hang on. Is your importer calling The Ruby API Model.import method?

            Yes it its. I'm making an ugly workaround for the missing <orientation> info. Basically using the built-in importer but also unzipping the KMZ and reading the KML file myself and making the necessary adjustments (tilt, rotation, heading) to the geometry in the model (according to angles from KML) before using the built-in exporter. Some other changes are also made but they are unrelated.

            Before this i've tried for days to fetch those angles somewhere in Sketchup but i finally came to the conclusion that the importer is broken - correct me if i'm wrong.

            Thanks for the quick reply! πŸ˜„

            1 Reply Last reply Reply Quote 0
            • tt_suT Offline
              tt_su
              last edited by

              I don't know much about the importers themselves. I have to ask someone else on the team - they are not online yet as they are all in the US.

              1 Reply Last reply Reply Quote 0
              • T Offline
                tireddude
                last edited by

                Ok thanks. Please post here when/if you get more information. It would be great if both problems could be solved somehow.

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

                  The Sketchup::Importer#do_options() example is totally wrong. (It is the terse, almost worthless, example for id().)

                  The API should explain how options are used and stored.

                  I'm not here much anymore.

                  1 Reply Last reply Reply Quote 0
                  • T Offline
                    tireddude
                    last edited by

                    @tt_su said:

                    I don't know much about the importers themselves. I have to ask someone else on the team - they are not online yet as they are all in the US.

                    Any news on this?

                    1 Reply Last reply Reply Quote 0
                    • tt_suT Offline
                      tt_su
                      last edited by

                      Sorry about the delay in response. The API is currently missing the ability to set import options. I ensured we had a feature request for it filed.

                      But it appear that what you do is a workaround for an issue with the existing importer. Would you mind describing the issue in detail and provide samples that illustrate?

                      1 Reply Last reply Reply Quote 0
                      • T Offline
                        tireddude
                        last edited by

                        @tt_su said:

                        But it appear that what you do is a workaround for an issue with the existing importer. Would you mind describing the issue in detail and provide samples that illustrate?

                        This shows a couple of problems i have ran into:

                        Start Sketchup
                        Make a cube
                        Geolocate model
                        Save as SKP
                        Export as "test_model.kmz"

                        • in KML now <Orientation><heading>-0</heading><tilt>0</tilt><roll>0</roll></Orientation>
                          Try kmz in Google Earth - OK
                          Close Sketchup
                          Start Sketchup
                          Import test_model.kmz
                          Modelinfo -> Geo-location "This model is not GeoLocated" it says
                          Check dictionaries (my own script - screenshot on this)
                        • Model has two(!) georeference dictionaries
                          Export to KMZ again "test_model_imp_kmz+exp_kmz.kmz"
                          Test in Google Earth even tho SU says "not geolocated" - OK (ends up in exact same spot as the first one)
                          Delete all but last GeoReference dictionaries in SU with own script
                          Check dictionaries
                        • Only one GeoReference entry exist now (see screenshot)
                          Modelinfo -> Geo-location "This model is accurately geolocated"
                          === END OF A PROBLEM WITH DUPLICATE GEOREFERENCE DICTIONARIES MAKING SU SAY "MODEL NOT GEOLOCATED" EVEN IF IT IS ===
                          Close Sketchup
                          Unzip "test_model.kmz"
                          Change under <Model> .... <Orientation> to random values
                        • <Orientation><heading>33</heading><tilt>-70</tilt><roll>-20</roll></Orientation>
                          Zip (with changes) and rename to "test_model_MOD.kmz"
                          Test in Google Earth "test_model_MOD.kmz" (should be "flying" now - OK)
                          Start Sketchup
                          Import "test_model_MOD.kmz"
                          Export to "test_model_MOD_imp_kmz_exp_kmz.kmz"
                          Test in Google Earth "test_model_MOD_imp_kmz_exp_kmz.kmz" (should be flying but it is NOT)
                          Look in the KML in "test_model_MOD_imp_kmz_exp_kmz.kmz"
                        • <Orientation><heading>-0</heading><tilt>0</tilt><roll>0</roll>
                          !! THE CHANGES ARE LOST !!

                        So this is basically why i need to parse the KML. I get models where roll/tilt/heading is set and when changes are made inside Sketchup and then exported to KMZ again, model ends up in wrong place in Google Earth. Well, its not in wrong place, its just rolled/tilted/rotated wrong actually but it looks like it is in the wrong place.

                        I will attach the files too.


                        Created and geolocated inside Sketchup then exported


                        Imported then exported


                        test_model.kmz modified heading roll tilt under the <Model> tag in KML


                        Modified imported then exported


                        Duplicate GeoRef dictionaries


                        After remove of duplicate GeoRef dictionaries

                        1 Reply Last reply Reply Quote 0
                        • T Offline
                          tireddude
                          last edited by

                          @tt_su said:

                          Sorry about the delay in response. The API is currently missing the ability to set import options. I ensured we had a feature request for it filed.

                          I forgot to say thankyou for this. Hope it gets sorted out. πŸ˜„

                          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