• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

[Plugin] ComponentReporter++ v1.2

Scheduled Pinned Locked Moved Plugins
71 Posts 22 Posters 62.5k Views 22 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.
  • M Offline
    mozarov
    last edited by 25 Sept 2021, 10:28

    Hi TIG, Thank you very much for the plugin. Is there a way to get all DCs reported within another DC?
    I've attached dynamic drawer model as an example. I'd like to get report of nested parts of a drawer.
    Thanks again.


    Dynamic drawer 210925.skp

    1 Reply Last reply Reply Quote 0
    • T Offline
      TIG Moderator
      last edited by 25 Sept 2021, 15:05

      If you edit the component-instance the nested instances should become accessible ?
      Then your reports will be based of the instances in each nested collection...

      TIG

      1 Reply Last reply Reply Quote 0
      • M Offline
        mozarov
        last edited by 27 Sept 2021, 12:32

        TIG thank you for quick answer. I have named component instances (ie right, left, bottom part etc.) inside dynamic drawer component but still get report of drawers outer dimensions only. I am trying to get report of inner parts of the drawer. Like your ComponentReporter++ cycles through all components and gives report of all components within other component. I would like to get same report of all mined nested DC parts of a DC drawer. Thanks again.

        1 Reply Last reply Reply Quote 0
        • M Offline
          mozarov
          last edited by 12 Feb 2022, 09:54

          Please help me out TIG. I am banging my head to a wall for months now. How to make your code cycle through nested DCs ant get their LenX, LenY, LenZ, other attributes to csv?
          Plaease help, I am stuck.


          Dynamic drawer 220210.skp

          1 Reply Last reply Reply Quote 0
          • T Offline
            TIG Moderator
            last edited by 12 Feb 2022, 11:44

            Doesn't my earlier posts about DCs cover this ?
            https://sketchucation.com/forums/viewtopic.php?p=659662#p659662
            Edit the object to access the DCs within it ?

            TIG

            1 Reply Last reply Reply Quote 0
            • M Offline
              mozarov
              last edited by 12 Feb 2022, 12:46

              Sorry I don't explain it right. Be selecting a drawer I get report of drawers "parent" attributes. Please see the attached picture.
              What I am trying to get is DC childrens report, like on the second screenshot.
              Please help me out.


              1 drawers DC attributes report.PNG


              2 drawers DC attributes mined report.PNG

              1 Reply Last reply Reply Quote 0
              • M Offline
                mozarov
                last edited by 16 Jan 2023, 07:45

                Hello TIG
                I have edited your code and it exports all DCs of the model. How to make it export only selected DCs?
                I think I have to write ss = model.selection line somewhere. But where should I put it?
                Thank you for your help.

                =begin
                (c) TIG 2011
                Script:
                TIG-exportDCs2csv.rb
                Type;
                  TIG.exportDCs2csv
                in the Ruby Console to run it.
                Exports all DCs is the model with a Name,LenX,LenY,LenZ,Layer[s]... 
                'CSV' file - in the model's folder and named after the model thus;
                ModelName.skp >>> ModelNameDCs.csv
                If a new model is unsaved the current directory receives the new file.
                All Layers used in the DC are listed by name and visible ones marked 
                thus >>LayerName<<
                Edit sep="," if something other than separating comma is desired e.g. ';'
                Make sep="\t" if a TSV file is desired and change ext="csv" to ext="tsv".
                It uses the current Model Units.
                Version;
                1.0 20111104 First issue.
                1.1 20111221 DCs customized.
                =end
                require 'sketchup.rb'
                ###
                module TIG
                  unless file_loaded?(__FILE__)
                	UI.menu("Plugins").add_item("TIG.exportDCs2csv2"){TIG.exportDCs2csv2()}
                  end
                  file_loaded(__FILE__)
                  def self.exportDCs2csv2() #Exports everything without selection
                  
                  
                  
                    sep="," ### <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                    ext="csv" ### <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                    model = Sketchup.active_model
                    defs=model.definitions
                    dcs=[]
                    defs.each{|dc|
                      next if not dc.attribute_dictionary("dynamic_attributes")
                      dcs << dc
                    }
                    if not dcs
                      UI.messagebox("No DCs were available.\nExiting.")
                	  return nil
                    end#if
                    insts = ss.grep(Sketchup;;ComponentInstance) #insts=[]
                    dcs.each{|dc|insts << dc.instances}
                    insts.flatten!
                    insts.uniq!
                    insts.compact!
                    data=[]
                    insts.each{|inst|
                      defn=inst.definition
                      #name=defn.name.tr(sep,"_")
                      repname=defn.get_attribute("dynamic_attributes","repname",0).to_s
                	  repmat=defn.get_attribute("dynamic_attributes","repmat",0).to_s
                	  rept=defn.get_attribute("dynamic_attributes","rept",0).to_s
                	  repl=defn.get_attribute("dynamic_attributes","repl",0).to_s
                	  repw=defn.get_attribute("dynamic_attributes","repw",0).to_s
                	  reppvc=defn.get_attribute("dynamic_attributes","reppvc",0).to_s
                      dat=repname+sep+repmat+sep+rept+sep+repl+sep+repw+sep+reppvc
                            
                      
                      data << dat
                    }
                    path=model.path
                    if not path or path==""
                      path=Dir.pwd
                      title="Untitled"
                    else
                      path=File.dirname(path)
                      title=model.title
                    end#if
                    ofile=File.join(path,title+'DCs.'+ext).tr("\\","/")
                    begin
                      file=File.new(ofile,"w")
                    rescue### trap if open
                      UI.messagebox("File;\n\n  "+ofile+"\n\nCannot be written - it's probably already open.\nClose it and try making it again...\n\nExiting...")
                	  return nil
                    end
                    data.each{|d|file.puts(d)}
                    file.close
                    puts (data.length.to_s)+" DCs written to\n"+ofile
                    puts 'DONE.'
                    begin
                      UI.openURL("file;/"+ofile)
                    rescue
                    end
                  end#def
                  
                end#module
                ###
                
                
                1 Reply Last reply Reply Quote 0
                • T Offline
                  TIG Moderator
                  last edited by 16 Jan 2023, 12:16

                  Edit this part:

                  model = Sketchup.active_model
                  defs=model.definitions
                  

                  to limits defs to those selected DC instances

                  model = Sketchup.active_model
                  #defs=model.definitions
                  ins = model.selection.grep(Sketchup;;ComponentInstance)
                  defs=[]
                  ins.each{|i|
                    next unless i.definition.attribute_dictionary("dynamic_attributes")
                    defs << i.definition
                  }
                  defs.uniq
                  
                  

                  There's probably a more elegant way to do this, but I'm trying to reuse the old code with minimal editing

                  TIG

                  1 Reply Last reply Reply Quote 0
                  • M Offline
                    mozarov
                    last edited by 17 Jan 2023, 17:07

                    Hello TIG
                    I have changed the piece of code you gave me but now it doesnt get nested childrens DC attributes. Only selected Parents cabinet attributes are reported. My dynamic cabinet has nested dynamic parts which contains DC attributes RepL, RepW and so on. Please help, just one tiny step left.
                    Here is the code I have now.

                    	model = Sketchup.active_model
                    	#defs=model.definitions
                    	ins = model.selection.grep(Sketchup;;ComponentInstance)
                    	defs=[]
                    	ins.each{|i|
                    	next unless i.definition.attribute_dictionary("dynamic_attributes")
                    	defs << i.definition
                    	}
                    	defs.uniq
                    		
                        dcs=[]
                        defs.each{|dc|
                          next if not dc.attribute_dictionary("dynamic_attributes")
                          dcs << dc
                        }
                        if not dcs
                          UI.messagebox("No DCs were available.\nExiting.")
                         return nil
                        end#if
                        insts=[]
                        dcs.each{|dc|insts << dc.instances}
                        insts.flatten!
                        insts.uniq!
                        insts.compact!
                        data=[]
                        insts.each{|inst|
                          defn=inst.definition
                          #name=defn.name.tr(sep,"_")
                          repname=defn.get_attribute("dynamic_attributes","repname",0).to_s
                         repmat=defn.get_attribute("dynamic_attributes","repmat",0).to_s
                         rept=defn.get_attribute("dynamic_attributes","rept",0).to_s
                         repl=defn.get_attribute("dynamic_attributes","repl",0).to_s
                         repw=defn.get_attribute("dynamic_attributes","repw",0).to_s
                         reppvc=defn.get_attribute("dynamic_attributes","reppvc",0).to_s
                          dat=repname+sep+repmat+sep+rept+sep+repl+sep+repw+sep+reppvc
                                    
                          data << dat
                        }
                    
                    1 Reply Last reply Reply Quote 0
                    • T Offline
                      TIG Moderator
                      last edited by 17 Jan 2023, 22:25

                      You asked for selected DCs I gave you that !
                      Now you want any DCs inside the selected DCs ??
                      That's much more convoluted.

                      You could find all DCs in the definitions that have instances, then reduce that list by testing for those in the selection, OR those that have a DC instance that has a parent that's the definition of one of the nested DC instances...
                      But as I said it complicated and beyond simple advice at the moment...
                      Perhaps someone else can chip in while I' very busy on other things...

                      TIG

                      1 Reply Last reply Reply Quote 0
                      • M Offline
                        mozarov
                        last edited by 18 Jan 2023, 06:49

                        Hi TIG
                        Thanks for your help. It just shows how little I understand abaut the task. May I ask for your permission to post this code somewhere else on the internet?
                        Besides if it isn't too hard I could pay for solving this problem. Please contact me if you interested.
                        Thanks again for your help.

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

                        Advertisement