sketchucation logo sketchucation
    • Login
    1. Home
    2. mconsidine
    3. Posts
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    🫛 Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download
    M
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 3
    • Groups 1

    Posts

    Recent Best Controversial
    • RE: Looping through components in a script?

      Okay, it looks like I'm getting close to what I want with the Export CI ID plugin :
      http://www.scriptspot.com/sketchup/scripts/export-ci-id
      Now to figure out a quick way of hiding everything not selected as I loop through.
      Thanks again for the help here - I am appreciative.
      Regards,
      Matt

      posted in Developers' Forum
      M
      mconsidine
    • RE: Looping through components in a script?

      Hi TIG,
      Thank you for your reply and the code snippet. As written I got a couple of errors, so I changed the middle section of what you provided to this

      until ((parent==model) || (parent==nil)) #MattC dats << parent.name if parent.class==Sketchup::ComponentDefinition if parent.instances[0] != nil #MattC parent=parent.instances[0].parent #MattC fix typo else #MattC parent=nil #MattC end #MattC end#until

      and this gets me the list hierarchy I was looking for. Dunno if I missed something else - there's certainly got to be a better way than what I wrote - but this seems to traverse the component tree.

      At the risk of prolonging this thread, can you suggest where I want to add code to "select" a component? I was working on looping through entities like this
      if (an_entity.typename == 'ComponentInstance') component_name = an_entity.definition.name puts(" Dealing with : " + component_name) status = our_selection.add an_entity #select it curritem = our_selection[0] if (curritem) puts(" Selected entity = " + curritem.name); else puts(" Some error") end UI.messagebox(component_name + " should be selected. ") subcomponents = curritem.explode #some recursion to to work down through the component status = our_selection.remove curritem #need to reassemble component here???? end
      hopting that the "Attribute Reporter" (attrreporter.rb) plugin could serve as a guide. But I'm getting stuck at the drill-down-and-reassemble point. Your approach would seem to naturally work better. Is there a plugin out there that you know of which you could point me to as a guide?

      (My end goal is to loop through a model to show different views of each component, for what it's worth.)

      I appreciate the help you've given on this - thanks!
      Matt

      posted in Developers' Forum
      M
      mconsidine
    • Looping through components in a script?

      Hi,
      I am trying to write a plugin to loop through the components in a model and display the unique name for each item. I've been through the "Hello World" example and reviewed other example plugins.

      In my example, I have a model with three components, each of which is comprised of a couple of sub-components. E.g.
      A
      a1
      a2
      B
      b1
      C
      c1
      c2
      c3

      If I do this (omitting the requisite definition statements earlier in the code)
      for i in 0..(component_definitions.length) if component_definitions[i] != NIL #UI.messagebox("Item " + i.to_s + " : " + component_definitions[i].name) end end
      I'll get a list of all the component names. If I specify "entities" instead of "component_definitions", then I correctly get a list of 3 items (though ".name" is not a valid qualifier).

      Can someone point me to a bit of code or a resource which would show me how to print out the full name of a component (e.g. A.a1, C.c3, etc.)? My goal is to be able to loop through the model, showing only one component at a time while hiding all the rest. If this (or something similar) has already been done and I could be pointed to that, I'd be appreciative.

      Finally, I'm new to this forum. I hope the above is appropriately phrased and that this is the right spot for the question. If I've made any newbie error, I apologize in advance.
      Regards,
      Matt

      posted in Developers' Forum
      M
      mconsidine
    • 1 / 1