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

    Help with componentdefinition=definitions.load name

    Scheduled Pinned Locked Moved Developers' Forum
    17 Posts 5 Posters 825 Views 5 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.
    • honoluludesktopH Offline
      honoluludesktop
      last edited by

      OK, let me try to explain better.

      1a. I open SU, either by selecting a .skp, or 1b. the SU shortcut (then open a .skp from a folder that the SU plugin is not in).
      2. I add a new .skp into the model as a component.

      Where name is not the absolute path name, componentdefinition=definitions.load name creates a definition of the new .skp in the model in the case of 1a, but not 1b. When name is the absolute path name, both 1a, and 1b. fail.

      I realize that not using the absolute path name seems wrong, but it worked, where using the absolute path name failed.

      1 Reply Last reply Reply Quote 0
      • honoluludesktopH Offline
        honoluludesktop
        last edited by

        What this seems to be telling me, is that componentdefinition=definitions.load name works when the active SU::Model folder is the same as the new .skp file. Or, I am somehow not getting the correct absolute file name. My code is:

        dir_name=File.dirname(model.path) name=dir_name+"\\"+filename+".skp"

        I have checked the result by puts name, and it looks OK.

        1 Reply Last reply Reply Quote 0
        • J Offline
          Jim
          last edited by

          I don't think a Definition will load if a definition already exists with the same path. Is this what's happening?

          Hi

          1 Reply Last reply Reply Quote 0
          • J Offline
            Jim
            last edited by

            Related?

            http://forums.sketchucation.com/viewtopic.php?f=180&t=28122

            Hi

            1 Reply Last reply Reply Quote 0
            • honoluludesktopH Offline
              honoluludesktop
              last edited by

              Maybe, how do I check? How do I delete an existing definition?

              1 Reply Last reply Reply Quote 0
              • honoluludesktopH Offline
                honoluludesktop
                last edited by

                @jim said:

                Related?

                http://forums.sketchucation.com/viewtopic.php?f=180&t=28122

                You posted while I was posting.:-) Went to viewtopic, but some of the discussion is "over my head". How do I cdef.save_as("/dev/null")? is "/dev/null", my "dive:/pathname/null"? Is cdef the existing cdef, or the new cdef?

                1 Reply Last reply Reply Quote 0
                • honoluludesktopH Offline
                  honoluludesktop
                  last edited by

                  More precicely:

                  1. I saved the transformations of a set of components.
                  2. Then deleted the components from the model.
                  3. Created a new definition from a new .skp.
                  4. Created components with the new definition and the saved transformations.

                  This cnt_instance.definition.save_as(File.dirname(model.path)+"\\null") returned, Error: #<TypeError: reference to deleted ComponentInstance>, where cht_instance is the deleted component.

                  I also tried definitions.purge_unused without success.

                  1 Reply Last reply Reply Quote 0
                  • C Offline
                    Cleverbeans
                    last edited by

                    @honoluludesktop said:

                    More precicely:

                    1. I saved the transformations of a set of components.
                    2. Then deleted the components from the model.
                    3. Created a new definition from a new .skp.
                    4. Created components with the new definition and the saved transformations.

                    This cnt_instance.definition.save_as(File.dirname(model.path)+"\\null") returned, Error: #<TypeError: reference to deleted ComponentInstance>, where cht_instance is the deleted component.

                    I also tried definitions.purge_unused without success.

                    Try switching steps 2 and 3. Once you delete the component referring to it will throw the error you're getting. If you require a reference to the instance in order to property do step 4, then add the new components to the model first and delete the old components afterwards.

                    1 Reply Last reply Reply Quote 0
                    • honoluludesktopH Offline
                      honoluludesktop
                      last edited by

                      Cleverbeans, Thanks, but didn't work.

                      1 Reply Last reply Reply Quote 0
                      • honoluludesktopH Offline
                        honoluludesktop
                        last edited by

                        Well, I completed my program, and did it by not using a path. It's my guess that SU keeps track of where SU is, so if you:

                        1. Save a component to file as name.skp.
                        2. Edit the saved file. (this is the function of the plugin)
                        3. Erase the component instances (that was saved) from the original model entities.
                        4. definitions.purge_unused
                        5. componentdefinition = definitions.load name.skp
                        6. entities.add_instance componentdefinition, each_transformation

                        The key to make this work is step 4. The only problem that can come about is if you require the erased components to remain in the select "Components" window.

                        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