sketchucation logo sketchucation
    • Login
    1. Home
    2. Pout
    3. Posts
    πŸ›£οΈ Road Profile Builder | Generate roads, curbs and pavements easily Download
    P
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 57
    • Posts 259
    • Groups 1

    Posts

    Recent Best Controversial
    • Send string value to Webdialog

      This is how it can be done (besides JSON)

      Example.

      In ruby

      name="blablabla"
      command = "_showdata('taskname', '#{name}')"
      dialog.execute_script(command)
      

      In webdialog

      function _showdata(id,value) {
      	var element = document.getElementById(id);
      	element.value = value; 
        	}
      

      The only problem i have is:
      Ruby continues interpreting script without waiting.
      For example: if the dialog is not yet open, you test on that and first open the dialog, the value will not be shown in the dialog. App. the ruby script just continues without waiting tille the dialog is open. Now if i place a UI.messagebox just before the command line all goes well.

      Is there any way to hold the ruby script so it only continues if the dialog script is executed? Or is there another way to do this?

      posted in Developers' Forum
      P
      Pout
    • Announcement: Sketchup Virtual Builder **UPDATE**

      A quick video preview on the developement of Sketchup Virtual Construction (4D)
      Will be available in 3 versions:

      Sketchup Virtual Builder Light:
      Attach date information to Sketchup objects. See and analyze the construction progress in Sketchup

      Sketchup Virtual Builder:
      Attach date information from external sources like MS Project, Primavera or Power Project. See and analyze the construction progress in Sketchup. Compare several schedulings and see the results of updated schedulings graphically in Sketchup

      xD Virtual Builder Sketchup datasource:
      Use Sketchup as a datasource in our xD Builder. An enviroment which makes it possible to centralize all project data into one database. Use Sketchup files and objects to represent buildings, traffic, costs etc. Visualize costs, traffic, construction progress and delay in Sketchup based upon direct information from the database.

      Click the image for the preview

      http://www.domos.be/4DSU.jpg

      Cheers!

      posted in Developers' Forum
      P
      Pout
    • RE: [poss. BUG] Best-Fastest way to loop through all objects

      ah thx, will give that a try πŸ˜„
      see if it goes faster

      posted in Developers' Forum
      P
      Pout
    • Attach a material library to an entity

      Is it possible to specify a material library for an entity/group/instance?

      So instead of going through all entities in an instance and changing their color, you just select another library for that instance.
      This to avoid the need to going into all objects of a 350.000 objects model

      posted in Developers' Forum
      P
      Pout
    • RE: [poss. BUG] Best-Fastest way to loop through all objects

      Rick,

      Thank you very much. Is it possible that when you just go into a group the group is also made unique?
      As I understand i can do it like this:

      • when it is a group show messagebox with 'group' in it
        execute the make_unique command
        for each entity in the group execute the loop again

      Correct?
      Or should it be possible to handle groups and instances in one loop
      like: if it is a group or instance do...

      posted in Developers' Forum
      P
      Pout
    • RE: [poss. BUG] Best-Fastest way to loop through all objects

      from the previous procedure i think i have found a bug in SU:

      setup:

      1. create a square and extrude it
      2. make a component of it
      3. bring another instance of the component in the model
      4. make a group of those two
      5. duplicate the group

      Now when looping i have set a 'flag':
      the loop

      • when it is a face show messagebox with 'face' in it
      • when it is a group show messagebox with 'group' in it
        for each entity in the group execute the loop again
      • when it is a instance show messagebox with 'instance' in it
        for each entity in the instance definition execute the loop again

      Now this give me this result:
      messagebox group
      messagebox instance
      messagebox group (automatically goes away and immediately shows:)
      messagebox instance
      ...

      Now this is not correct.

      If, before i execute the loop, i just go into one of the two groups (just double click it and click next to it again) this is the result when executing the loop:
      messagebox group
      messagebox instance
      messagebox face (6 times)
      messagebox instance
      ...
      This is correct.

      Is there any know bug about this? It seems SU threats the loop differtly just based upon a single 'not changing anything' action.
      Can someone please verify? And maybe give some advise?
      Thx!!

      posted in Developers' Forum
      P
      Pout
    • [poss. BUG] Best-Fastest way to loop through all objects

      Facts of our dev.

      1. In certain objects we store a generated ID in the data dictionary (Since the id from Sketchup changes each time you open the model)
      2. We have a list that contains some of those ID's
      3. We want to give all the objects that are in that list another color.

      Now.
      We have that working but it is slow, probabbly because:

      • We loop through all SU objects and see if their ID is listed in the list of ID's. So in some cases up to 99% of the loop is not necessary. Isn't it possible to make this faster? Instead of looping and checking each time, just like 'pick' them?
      • To change the color we have a procedure:
        check if the selected object is a group-entity-instance
      1. if entity: set material to red
      2. if group: go in the group and execute the procedureagain
      3. if instance; go in the instance and execute the procedureagain

      So we like go into the element, go to it's smallest 'part' and change the color of that part.
      It would off course be easy to just set the group material or instance material to red but that does not override the material of the elements in the group/instance.

      As you can imagine: if an instance contains a group and then another instance with 25 entities in that the loop tends to take a long time.
      What is the fastest way to loop through all objects?

      Thx πŸ˜„

      posted in Developers' Forum
      P
      Pout
    • RE: Component inst to component Def in a Selection

      Looks interesting.
      I think i can use this in a loop we have analyzes all objects and can contain several instances.
      Thx πŸ˜„

      posted in Developers' Forum
      P
      Pout
    • RE: Coming Soon:Profile Builder

      Very very nice. Reminds me of the Revit Architecture Suite possibilities and that in SU!!
      Are you thinking of using this for BIM purposes?

      Would be honored to test it πŸ˜„

      posted in Developers' Forum
      P
      Pout
    • Ruby scripting interface

      What program do you use to write your ruby code in? And does it 'color' comments etc. differently?

      Thx

      posted in Developers' Forum
      P
      Pout
    • RE: Change the color of only one instance

      Ok i have found that (jeez, i should stop posting when something pops up in my mind)
      Almost finished.
      I'll post my code soon.

      posted in Developers' Forum
      P
      Pout
    • RE: Change the color of only one instance

      Does anyone know how i can give a component definition a certain name?
      When making an instance unique it automatically adds #1 behind the current component definition name.

      posted in Developers' Forum
      P
      Pout
    • RE: Change the color of only one instance

      ok i have my script (almost working)

      def cinchange
      #--initialize--
      model=Sketchup.active_model
      ss=model.selection.first
      UI.messagebox('selection OK')
      ########################
      #--Change the instance--
      ########################
      #--Get component definition of instance--
      compdef=ss.definition.name
      UI.messagebox('definition OK')
      #--Write component def. to instance dictionary
      ss.set_attribute 'xdid_dict', 'compdef', compdef
      UI.messagebox('attribute OK')
      #--Make instance unique (creates new comp. definition)--
      ss.make_unique
      UI.messagebox('unique OK')
      #--Edit the instance (make all entities red)--
      compdef2=ss.definition
      ent=compdef2.entities
      ent.each {|i|
              if i.typename=="Face"
                i.material="red"
                i.back_material="red"
                end
              }
      UI.messagebox('rood OK')
      UI.messagebox('total succes')
      end
      def cinrestore
      
      #########################
      #--Restore the instance--
      #########################
      #--Get current component definition of instance--
      model=Sketchup.active_model
      ss=model.selection.first
      UI.messagebox('selection OK')
      #--Get the component definition defined in the attrib. dict.--
      orig_compdef=ss.get_attribute 'xdid_dict', 'compdef'
      UI.messagebox(orig_compdef)
      #--If no comp. definition set in the attrib. dict., do nothing--
      #--If comp. def. set in attrib. dict. does not equal current comp. def., set the component definition from the attrib. dict. back--
      current_compdef=ss.definition.name
      UI.messagebox(current_compdef)
      if orig_compdef!= current_compdef
      UI.messagebox('niet gelijk')
      ss.definition=orig_compdef
      end
      

      The only problem left is how to set the definition of the instance back to the original one based upon the variable orig_compdef which is the name of the definition.
      I have saved the original 'name' of the component definition in the attrib. dictionary cause appaerently it is not possible to save the definition itself.
      Can someone help me on this? --> SOLVED

      Also, could you check if it is possible to make this script 'better'?

      Thx πŸ˜„

      posted in Developers' Forum
      P
      Pout
    • RE: Change the color of only one instance

      lol Gaieus
      Well i thought i asked it in the component section πŸ˜„
      The thread we had going on there was very helpfull to see the posibilities and clear my mind of what exactly i wanted it to do.
      I now have the basics of it but still there are some major issues.

      Here is the code:

      def cinchange
      ########################
      #--Change the instance--
      ########################
      #--initialize--
        model=Sketchup.active_model
        ss=model.selection.first
      #--Get component definition name of instance--
        compdefname=ss.definition.name
      #--Write component def. to instance dictionary
        ss.set_attribute 'xdid_dict', 'compdefname', compdefname
      #--Make instance unique (creates new comp. definition)--
        ss.make_unique
      #--Edit the instance (make all entities red)--
        compdef=ss.definition
        ent=compdef.entities
        ent.each {|i|
                if i.typename=="Face"
                  i.material="red"
                  i.back_material="red"
                  end
                }
      end
      
      def cinrestore
      #########################
      #--Restore the instance--
      #########################
      #--initialize--
        model=Sketchup.active_model
        ss=model.selection.first
      #--Get current component definition of instance--
        current_compdefname=ss.definition.name
      #--Get the component definition defined in the attrib. dict.--
        orig_compdefname=ss.get_attribute 'xdid_dict', 'compdefname'
      #--If comp. def. set in attrib. dict. does not equal current comp. def., set the component definition from the attrib. dict. back--
          if orig_compdefname
            if orig_compdefname!= current_compdefname
            definitionlist=model.definitions
            ss.definition=definitionlist[orig_compdefname]
      #--Delete the current component definition from the library--
      #--Delete the attrib. dict. entry from the instance
        end
        end
      end
      
      

      The issues are:

      • what to do when there is only one instance of a component present in the model. make unique does not work then. (any thoughts on this?)
      • now for each instance of the same component it creates a new component definition while it could reuse the first one. (dito)
      • get the attribute information out of the instances dictionary

      I don't know if anyone could use the above script and if i need to put it in a plugin or something.

      posted in Developers' Forum
      P
      Pout
    • RE: Change one instance of a component

      continued here: http://www.sketchucation.com/forums/scf/viewtopic.php?f=180&t=13901

      posted in SketchUp Discussions
      P
      Pout
    • RE: Change the color of only one instance

      Thank you Tig,

      Sounds like the setup we thought about yesterday.

      This is the processflow we were thinking about:

      Change color depending on script result

      1. Get the component definition of the instance
      2. Write this component definition as an attribute in the instance attribute dictionary
      3. Make the instance unique (this results in a new component definition)and give it a name (can we use the auto-component name generator from SU itself?)
      4. Loop through all the entities in the component and set color as red

      Reset color

      1. Check to see if the current instance component definition equals the component definition that is available in the attribute dict of the instance
      2. If there is a difference: give the instance the component definition it has set in it's attribute dictionary.
      3. Delete the 'current' component definition from the component library

      Is this a good way? Thx again

      posted in Developers' Forum
      P
      Pout
    • RE: Change the color of only one instance

      i'm posting my progress.

      To change the component definition from an instance i have found.

      Leaves me with 2 questions:

      • Can i copy the 'in model' components in the library
      • Secondly: how do i set all those copied components to be red? (also the internal geometry of the component)

      thx

      posted in Developers' Forum
      P
      Pout
    • RE: Change the color of only one instance

      i'm just thinking of another question:
      Is there a way to edit, with ruby the colors of the contents of a component (the geometry) So a loop through the geometry of the component and change all the materials/colors of them.

      posted in Developers' Forum
      P
      Pout
    • Change the color of only one instance

      Hello all,

      They referred me to the ruby section to find a answer for my question. See also: http://www.sketchucation.com/forums/scf/viewtopic.php?f=15&t=13891

      In short:

      We are looking for a method to temporary change the clor/material of one or more instances without influencing the other instances of the same component.
      When the component elements have no color/material defined there is no problem. The color/material can be set on component level.
      But when the elements of the component have a color defined before they were turned into a component the color cannot be changed. (at least not on the component level)

      Now, based upon the result of a script an instance should be temporary colored in a different then original color/material BUT without losing the link with the original component.

      Is there a way to do this? We were thinking about creating (duplicating) a stand-in component with the color red and make all the instances that need to be red, instances of this stand-in component. With a hit on a button (or another script result) they should become instances of the original component again.

      Easiest way would be if an instance has an attribute that defines the source component and we just temporarily change that.
      is there such an editable attribute? Or are there better methods to accomplish this?

      Thx!

      posted in Developers' Forum
      P
      Pout
    • RE: Change one instance of a component

      thanks a lot! All help is really appreciated.

      posted in SketchUp Discussions
      P
      Pout
    • 1 / 1