sketchucation logo sketchucation
    • Login
    1. Home
    2. goga63
    3. Posts
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
    G
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 15
    • Posts 59
    • Groups 1

    Posts

    Recent Best Controversial
    • RE: How to create the pulldown menu for DC

      @jim said:

      You know where the DC Attributes are stored, so now you can inspect the "dynamic_attributes" Dictionary to see how to recreate any DC you find.

      Here is a basic example of a dropdown list with 3 options:

      Code:

      sang = Sketchup.active_model.entities[0]
          sang_def = sang.definition
      
          sang_def.set_attribute 'dynamic_attributes','test', 'yes'
          sang_def.set_attribute 'dynamic_attributes','_test_access', 'LIST'
          sang_def.set_attribute 'dynamic_attributes','_test_formlabel', 'My test'
          sang_def.set_attribute 'dynamic_attributes','_test_label', 'my_test'
          sang_def.set_attribute 'dynamic_attributes','_test_options ','&yes=yes&no=no'
          sang_def.set_attribute 'dynamic_attributes','_test_units', 'STRING'
      

      Result on the image
      What do I do not so?


      menu.jpg

      posted in Developers' Forum
      G
      goga63
    • How to create the pulldown menu for DC

      Hi !
      I learn to write scripts for Sketchup, вut has rested against a wall...
      I can set attributes of components this code:

      entity.set_attribute 'dynamic_attributes','price', '0'
      entity.set_attribute 'dynamic_attributes','_price_label', 'price'
      entity.set_attribute 'dynamic_attributes','_price_formlabel', 'Price'
      entity.set_attribute 'dynamic_attributes','_price_units', 'STRING' entity.set_attribute 'dynamic_attributes','_price_access', 'TEXTBOX'
      

      It works!
      But I could never understand how to write code using meta attributes to create the pulldown menu for DC ...
      Show me a code fragment which it does.
      Thanks !

      posted in Developers' Forum
      G
      goga63
    • Atributes size

      Hi! Recently I needed to receive attributes of the sizes.
      I use a code:

      size_x = entity.bounds.width    # size on axis X
      size_y = entity.bounds.height   # size on axis Y
      size_z = entity.bounds.depth    # size on axis Z
      

      It works but at turn of a component the sizes are interchanged the position (image 1) - because the bounding-box relates to the model's axes, not the component's axes. I cannot use it.
      The code was!!! It has prompted Dan Rathbun. Here the decision:
      "...Some where at the top of your code where you do require statements:

       unless $".any?{|path| path =~ /dcutils.rbs/i }
          if Sketchup;;version.to_i < 13
            Sketchup;;require("dynamiccomponents/ruby/dcutils")
          else
            Sketchup;;require("su_dynamiccomponents/ruby/dcutils")
          end
        end # unless "dcutils" is already loaded
      

      We need this file loaded in order to add several methods
      to Components (and Groups,) that the DynamicComponents uses.

      If the user has switched OFF the DC extension, we must load
      at least, the "dcutils" file.

      It adds the instance methods below to ComponentInstance:•local_transformation()
      •last_scaling_factors()
      •scaled_size()
      •unscaled_size()
      It also adds these instance methods to Transformation:•rotx()
      •roty()
      •rotz()
      •xscale()
      •yscale()
      •zscale()

      Then where ever you need to use those additional methods:

       size_x, size_y, size_z = entity.scaled_size()
      

      I know, these additonal API methods should be documented in the API Dictionary. We (developers) have filed requests for this!..."
      Thanks, Den!

      posted in Developers' Forum
      G
      goga63
    • AutoRedraw

      Hi, there is a component which has a subcomponent .
      Material subcomponent =parent!Material
      the material of the parent component is no formula.
      The parent material changes after applying the Paint Bucket tool
      but to see the changes you must apply for a Redraw .
      Is there a plugin or code that makes auto Redraw when applied Paint Bucket .


      probe2.skp

      posted in Developers' Forum
      G
      goga63
    • RE: Dynamic vector Brick pattern

      you need it ?
      http://www.youtube.com/watch?v=OmeCQzRtxaU
      http://www.youtube.com/watch?v=ZE-yAwAjRcs

      posted in Dynamic Components
      G
      goga63
    • RE: How to copy an object in XYZ by using scale in DC. ??

      DareDevil, thank you

      posted in Dynamic Components
      G
      goga63
    • RE: How to copy an object in XYZ by using scale in DC. ??

      HI, tell us how you did it

      posted in Dynamic Components
      G
      goga63
    • A problem with OPTIONINDEX Function

      Why OPTIONINDEX Function shows different values ?
      and OPTIONLABEL Function too ?


      problem.jpg


      problem2.jpg


      optionindex_function.skp


      optionlabel_function.skp

      posted in Dynamic Components sketchup
      G
      goga63
    • RE: Dynamic Components reacting to Scene (aka Page) changes

      Dan , thanks for your help. I will study it.

      posted in Developers' Forum
      G
      goga63
    • RE: Dynamic Components reacting to Scene (aka Page) changes

      Dan, thank you for taking the time to answer my question
      In the source code in line :

      # Here we are allowing the scene trigger attributes to only have the values 
       # 1, 2, 3, and 4. 
       attributes[SCENE_TRIGGER] = (((attributes[SCENE_TRIGGER].to_i+1)%5)).to_s  
      

      determined how many scenes will loop. I would like to change this setting without changing the code. For this I am trying to use the InputBox. Вut my knowledge is not enough. can you help me ?
      P.S. Sorry for my English, I use Google translator

      posted in Developers' Forum
      G
      goga63
    • RE: Dynamic Components reacting to Scene (aka Page) changes

      the plugin works perfectly. But I would like to add the ability to input values for scene changes.
      I added code first :

      menu = UI.menu("PlugIns").add_item("Scenes") {
        prompts = ["looping scene ?  "]
        input = UI.inputbox prompts
        $sOptions_scenes=input
          }
      

      you can now set the number of scenes in the cycle
      and changed the code:

      attributes[SCENE_TRIGGER] = (((attributes[SCENE_TRIGGER].to_i+1)%5)).to_s
      

      ...to this:

      scene_loop = [$sOptions_scenes].to_i
      attributes[SCENE_TRIGGER] = (((attributes[SCENE_TRIGGER].to_i+1)%scene_loop)).to_s 
      

      unfortunately the last piece of code does not work
      Can someone suggest a solution ?
      Here's the entire code of the modified plugin:

      #useful constants
      # Copyright 2005-2008, Google, Inc.
      
      # Permission to use, copy, modify, and distribute this software for 
      # any purpose and without fee is hereby granted, provided that the above
      # copyright notice appear in all copies.
      
      # THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
      # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
      # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
      #
      
      # This code snippets allows you to have Dynamic Components 
      # that modify themselves based on a Scene Change
      #
      # They need to have at the top level the following attributes
      # "scene_change" a boolean value that if true force the DC to react to scene changes 
      # and if false has the DC ignore the scene change
      # and
      # "scene_trigger" which is the index that is incremented every time there is a scene change and 
      # it is used to change attributes for the DC.  
      
      
      
      # Attach our observer.
       menu = UI.menu("PlugIns").add_item("Scenes") {
        prompts = ["looping scene ?  "]
        input = UI.inputbox prompts
        $sOptions_scenes=input
          }
      
      
      # Copyright 2005-2008, Google, Inc. 
      
      # Permission to use, copy, modify, and distribute this software for 
      # any purpose and without fee is hereby granted, provided that the above 
      # copyright notice appear in all copies. 
      
      # THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR 
      # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 
      # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 
      # 
      
      # This code snippets allows you to have Dynamic Components 
      # that modify themselves based on a Scene Change 
      # 
      # They need to have at the top level the following attributes 
      # "scene_change" a boolean value that if true force the DC to react to scene changes 
      # and if false has the DC ignore the scene change 
      # and 
      # "scene_trigger" which is the index that is incremented every time there is a scene change and 
      # it is used to change attributes for the DC. 
      # 
      # 
      # Author; Simone Nicolo 
      
      require 'sketchup.rb' 
      
      
      # Define the Frame Change Observer which is documented in the Pages class. 
      class FrameChangeObserver 
      
      def initialize 
      # @current page is used to make sure that the observer is only triggered by page changes 
      # This is to workaround the PC bug that does not correctly populate the fromPage variable in the 
      # callback to frameChange. 
      @current_page = Sketchup.active_model.pages.selected_page 
      
      
      end 
      
      # Callback triggered by the Frame change observer. 
      # fromPage is populated with the page we were coming from, toPage is 
      # populated with the page we were transitioning to 
      # and percent done contains the percentage of the transition that 
      # has completed. 
      def frameChange(fromPage, toPage, percent_done)
      
      # If there has been a page change and it has completed 
      if (not toPage.nil? and percent_done == 1) then 
      if @current_page != toPage then 
      #update the current page 
      @current_page = toPage 
      #find the DCs that need redrawing, and redraw them. 
      find_dc_for_redraw 
      end 
      end 
      end 
      
      # This function finds all the DC's that need to be redrawn based on a scene transition and 
      # on the boolean scene_change attribute if scene_change is true, change and redraw 
      # the DC on a scene transition, if it is false do not change or redraw the DC. 
      def find_dc_for_redraw  
      
      
      entities_list = Sketchup.active_model.entities 
      
      if entities_list != [] 
      # For all the entities in the model 
      entities_list.each do |item| 
      type = item.typename 
      case type 
      # Find the Dynamic Component instances 
      when "ComponentInstance" 
      if not item.attribute_dictionaries.nil? 
      attributes = item.attribute_dictionaries[DICTIONARY_NAME] 
      # If they have a scene_change attribute that contains true 
      if (not attributes.nil? and attributes[SCENE_CHANGE] == 1.to_s) 
      # Increment the scene_trigger attribute. 
      # Here we are allowing the scene trigger attributes to only have the values 
      # 1, 2, 3, and 4. 
      
      
      scene_loop = [$sOptions_scenes].to_i
      
      attributes[SCENE_TRIGGER] = (((attributes[SCENE_TRIGGER].to_i+1)%scene_loop)).to_s 
      if attributes[SCENE_TRIGGER] == "0" then 
      attributes[SCENE_TRIGGER] = 1.to_s 
      end 
      # Redraw the DC using the $dc_observers global variable. 
      $dc_observers.get_latest_class.redraw_with_undo(item) 
      end 
      end 
      end 
      end 
      else 
      UI.messagebox("There are no entities in this model!") 
      end 
      end 
      
      end 
      
      if not file_loaded? 'scenes.rb' 
      # Useful constants 
      # Dynamic Components dictionary name 
      DICTIONARY_NAME = "dynamic_attributes" 
      # Boolean attribute that turns on and off the reaction to a scene change for the DC
      SCENE_CHANGE = "scene_change" 
      # Index attribute for the DC that is used to drive changes in the DC. 
      SCENE_TRIGGER = "scene_trigger" 
      # Attach the frame chage observer to the global Pages object. 
      id = Sketchup;;Pages.add_frame_change_observer(FrameChangeObserver.new) 
      file_loaded 'scenes.rb' 
      end 
      
      posted in Developers' Forum
      G
      goga63
    • RE: Cutting Optimization Pro with SketchUP

      posted in Woodworking
      G
      goga63
    • RE: Roundup Function

      =ROUND(LenX/9,0)

      posted in Dynamic Components
      G
      goga63
    • DC Predefined Attributes (Creator)

      Hello all.
      What does attribute ?: "Creator"


      Creator.jpg

      posted in Dynamic Components sketchup
      G
      goga63
    • RE: Fixed area on X / Y scale

      you want to do it ?


      floor.jpg


      floor.skp

      posted in Dynamic Components
      G
      goga63
    • RE: Dynamic double door not quite right

      Hi,this is because the right door is not a unique component...
      try this...


      DoubleDoor2.skp

      posted in Dynamic Components
      G
      goga63
    • RE: Animation of cabinet drawer causing reposition issues

      Fix it...


      cabinet.jpg

      posted in Dynamic Components
      G
      goga63
    • RE: Formula needed!!!

      try using a plug-in Solid Quantify by TAK2ATA. author website http://sketchup-onigiri.jimdo.com/plugin-other/

      posted in Dynamic Components
      G
      goga63
    • Dynamic Components that react to scene

      in far 2009 of Simone Nicolo created "Dynamic Components that react to scene (aka page) changes."
      http://sketchupapi.blogspot.ru/2009/07/dynamic-components-that-react-to-scene.html
      Sketchup plugin works in 2013. Can someone change the realties plugin to scene_trigger attribute, so it gave no number and the name of the scene? For example: scene_trigger = Scena2
      PS: Sorry for my English - I use Google translator
      http://www.youtube.com/watch?v=mpZU1ccDDts


      question.jpg

      posted in Dynamic Components sketchup
      G
      goga63
    • 1 / 1