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

    Name of the top parent

    Scheduled Pinned Locked Moved Developers' Forum
    7 Posts 3 Posters 297 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.
    • G Offline
      goga63
      last edited by

      Hi !
      There is a component with what structure:

      Model

      Top parent
      |
      parent
      .
      .
      .
      parent
      |
      child

      Whether there is a method to learn for "child" a name "Top parent"?
      On an example "Generate Report" 1 column "PATH" shows a way to "child"
      And if to take a name of a component 2 levels (a column "LEVEL") we learn a name "Top parent". If I have correctly understood that it is necessary to connect still a file dcclass_v1.rbs.
      But what is necessary a code for reception of a name of a component 2 levels ("Top parent")?


      top parent.jpg

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

        IF you (or the user,) is in edit mode of Component#2, then:
        Sketchup::active_model.active_path
        will return an array of the nesting path.

        Otherwise inst.parent() returns the definition who's entities collection contains this instance.

        But, if the parent definition has multiple instances in the model,... which one of those instances is the one wrapping the lower instance ?

        There may not be a way to tell ??

        I'm not here much anymore.

        1 Reply Last reply Reply Quote 0
        • G Offline
          goga63
          last edited by

          How Generate Report obtains this data without being in a mode of editing of a component?

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

            Generate Report traverses the whole model from model.entities and traverse over everything in the model.

            However, given an arbitrary component instance it's not possible to always get an exact hierarchy path to it's parents because it might be contained within multiple other instances - in which case you have ambiguity to what the correct result would be.

            1 Reply Last reply Reply Quote 0
            • G Offline
              goga63
              last edited by

              ok. I have understood it.
              On image1 the way for the chosen component 5 is shown.
              On image 2 the component 3 is allocated,
              By means of a code I obtain the data for a component 1.

              any_attribute = entity.get_attribute ("dynamic_attributes", "any_attribute", 0).to_s 
              

              can I somehow temporarily make the component 1-active , will receive path, and revert to a previous state?


              image1.jpg


              image2.jpg

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

                There is no way to change the active context in the Ruby API. You can only close it.

                But it doesn't change the problem. If you have one component instance, there is is no way to knowing where it belong to.

                Say we have a component "A". There is an instance of it in component "B". Say we have two instances of component "B": if we have a references to the instance of "A" it is impossible to tell which of the instances it belong to - because the very same instance of "A" exist at the same time in both instances of "B". Or to be more specific, An instance of "A" exist in the definition of "B". We can only trace the parent of "A" to the definition of "B" - not the instances.

                
                Model
                  ╠═B
                  ║ ╚A
                  ╚═B
                    ╚A
                
                

                You need context do determine where it belong to.

                What is it you are making? What is the goal you are trying to achieve?

                1 Reply Last reply Reply Quote 0
                • G Offline
                  goga63
                  last edited by

                  @tt_su said:

                  ...What is it you are making? What is the goal you are trying to achieve?

                  I wanna make it


                  report.jpg

                  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