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

    Posts

    Recent Best Controversial
    • Ruby scripted Dynamic Attributes reporting Issues

      Hello to Everyone,

      In 2016 I began to script a little tool to create some Dynamic Components,
      with added Information, for Edgebanding and different Materials,
      In the first Iteration I just made a cube, which was then changed thru the
      DC Component options to the needed Size, that worked as expected.

      Recently I took a look at the Code and changed it, that the drawn Cube has the
      right Size, as the User has to put them in an Inputbox-Prompt,
      The Components are created using the Point-Method and then Pushpulled (in Ruby).

      However, I dont get it why I cannot get the lenx, leny and leny to report in any
      Ruby- driven Report-Script I tried, until some User-Interaction with the
      Component-Options has been made,
      (just clicking in the Inputbox of the DC-Settings-Dialog and applying the already correct Values)
      since the Original Report-Feature can report these Values without this User-Interaction.

      As far as I can see, the Variables are correctly set, since the DCs are working
      as they should besides the Reporting-Thing.

      attached is a drawing with some of the scripted Components

      Has anyone a clue how I can make them readable to a script?

      Thank you in advance!


      script generated Components

      posted in Developers' Forum
      JHJ
      JH
    • RE: How do I correctly set the Length formulas in a DC via Ruby

      Whow! πŸ˜„ πŸ‘ 😎

      This seems to work,
      Now I just need to take care of the units.
      I will post a reply if I get the Script in a usable condition.

      It would be nice if You could take a look at it then.

      But I don't know when I'll get enough time for this.
      Maybe tomorrow, I got 2go and make Dinner, my Girlfriend already has the knife in her hand 😲
      and I don't want her to use it on me. πŸ˜†

      EDIT:
      I kept using the initial approach in setting the Lenx to _lenx_formula since
      the other way it left me with an unscalable Component, or at best with a scalable component which doesnt show the correct measurements as the corresponding values in the
      DC Dialog.
      But Hey, Thank You anyway, maybe someone else has use for the Code for another
      useful Plugin πŸ˜„ πŸ‘

      posted in Developers' Forum
      JHJ
      JH
    • RE: How do I correctly set the Length formulas in a DC via Ruby

      Thank you Jim,

      I think this is a step in the right direction,
      bur with the Test code U posted I get the Values in red #
      still not updating.
      and in the Attribute Inspector it shows some weird errors.


      DC Editor.PNG


      Attributeinspector.PNG

      posted in Developers' Forum
      JHJ
      JH
    • RE: How do I correctly set the Length formulas in a DC via Ruby

      Thank you very mouch,

      But this doesnt seem to function properly,
      In the Attribute Editor I get 0 instead of a self updating value


      DC Editor.PNG

      posted in Developers' Forum
      JHJ
      JH
    • How do I correctly set the Length formulas in a DC via Ruby

      Hello to all !

      After reading a lot of everything that Icould find
      on the net which was related to Dynamic Components and Ruby,
      and a good Hint from Dan Rathburn πŸ‘ , I managed to add
      Lenx, Leny and Lenz to a Component I created with Ruby. πŸ˜„

      But I cannot find out how to set the _lenx_formula,
      _leny_formula and _lenz_formula correctly, which means
      if I manually enter a value in the DC Dialog it works,
      but not if I set the Values from Code thru a simple dialog box. 😠

      Any help would be very appreciated ❗

      Sample code:

      #set the component dictionary
      @Component_dictionary = 'dynamic_attributes'

      First prompt for the dimensions. This is done using the inputbox

      method. In this case, we will actually use a wrapper for UI.inputbox

      that is defined in sketchup.rb which does some extra error checking

      The first step is to create some arrays which contain the prompts

      and default values.

      prompts = [("Bemerkung"),("Artikel"),("Laenge"), ("Breite"),("Staerke"),("Kante_links"),("Kante_rechts"),("Kante_oben"),("Kante_unten"),("Belag_Vorn"),("Belag_hinten")]

      values = ["BodenDecke","Material1", 600.mm, 400.mm, 19.mm,"Kante1", "Kante1","","","",""]

      list = ["", "Material1|Material2|Material3|Material4|Material5|Material6", "", "", "","|Kante1|Kante2|Kante3|Kante4|Kante5|Kante6","|Kante1|Kante2|Kante3|Kante4|Kante5|Kante6","|Kante1|Kante2|Kante3|Kante4|Kante5|Kante6","|Kante1|Kante2|Kante3|Kante4|Kante5|Kante6","|Belag1|Belag2|Belag3|Belag4|Belag5|Belag6","|Belag1|Belag2|Belag3|Belag4|Belag5|Belag6"]

      results = UI.inputbox(prompts, values, list, "Boden")

      lenx_formula=laenge.to_f
      leny_formula=breite.to_f
      lenz_formula=staerke.to_f

      comp1_def.definition.set_attribute @Component_dictionary,'lenx', '_lenx_formula'
      comp1_def.definition.set_attribute @Component_dictionary,'_lenx_label', 'LenX'
      comp1_def.set_attribute @Component_dictionary,'lenx', '_lenx_formula'

      comp1_def.definition.set_attribute @Component_dictionary,'leny','_leny_formula'
      comp1_def.definition.set_attribute @Component_dictionary,'_leny_label', 'LenY'
      comp1_def.set_attribute @Component_dictionary,'leny','_leny_formula'

      comp1_def.definition.set_attribute @Component_dictionary,'lenz', '_lenz_formula'
      comp1_def.definition.set_attribute @Component_dictionary,'_lenz_label', 'LenZ'
      comp1_def.set_attribute @Component_dictionary,'lenz', '_lenz_formula'

      $dc_observers.get_latest_class.redraw_with_undo
      (comp1_def_instance)

      posted in Developers' Forum
      JHJ
      JH
    • RE: Need Help adding predefined dynamic Attributes via Ruby

      Allright, Got it partly working, πŸ˜„

      But I Cant get the Attribute-Inspectors to show the
      Values, I guess I dont really understand how
      to set the Formulas correctly to get the corresponding Values by now.

      The DC Browser shows the Values (Lengths of the Piece in X,Y and Z)
      but everything else does not, this means no reporting so far.

      Can anybody push me a little in the right Direction ❓

      Where do I have to set the DC Attributes Instance or Definition?
      and how could I set it to both if needed?

      I tried to set it to the Definition and the second time I run the Script
      the created Geometry has no Attributes at all, or at least nothing
      important.


      The unfinished Script, still buggy

      posted in Developers' Forum
      JHJ
      JH
    • RE: Need Help adding predefined dynamic Attributes via Ruby

      Thank You very mouch for the Info,
      I didnt know that there is a plugin that shows the normally hidden
      Attributes.

      Very useful, I guess I got some homework to do now πŸ˜‰

      posted in Developers' Forum
      JHJ
      JH
    • Need Help adding predefined dynamic Attributes via Ruby

      Hello To all !! πŸ˜‰
      I am trying to create a useful Plugin for creating a simple Box
      in Ruby via User Input, then storing the Input Informations to the "dynamic_attributes"
      Dictionary.

      As a starting-Point I took the Box.rb from the Examples-Plugin and extended it
      a little.

      So far everything worked beautifully, since there are Heaps of Example-Code
      for this type of task and any Custom Attribute (info) that I store seems to be showing too.

      However,what I would like to do now is to manually add the LenX, LenY and LenZ Attributes
      to the Component (with Ruby) without setting a fixed Value aka "=Value" so that I can benefit from all the nifty observers that take care of auto-updating the corresponding Values thru a change.

      That would be very helpful since I dont want to use the right click menu all the time
      to add LenX, LenY and LenZ to every Part that is needed and I could also continue
      to use FredoScale (one of my favs in everyday use) and at the same time get accurate results in the Report.

      Sadly I didnt find any Very useful Code that explains how to handle the Formulas
      that are used to store the actual Value of the coresponding Attributes inside the DC.
      (besides the custom ones where a few snippets can be found (Sangs Color from Scott Lininger)).

      Any Help would be very appreciated since I am starting to get crazy over this.

      PS: I Apologise for my Bad English and I am Hoping anyone can help

      posted in Developers' Forum
      JHJ
      JH
    • Strange DC behavior or is it just me ? Found the Mistake!

      Hello to all You Sketchup-Wizards and Code-Magicians πŸ˜‰

      This is my first try to ask for a Hint, if somebody has
      a Clue what I am doing wrong.
      I started using some code-Snippets from SU Examples for
      creating simple Geometry using Points and PushPull.
      Then I rotated the createt geometry and redrawed it as new Instance.

      Then I started adding custom Attributes to the
      dynamic_attributes Dictionary (with Ruby, not with the GUI).

      I need the attached Attributes for using with a Program
      which we use for Calculating Cost, creating Cutlists,
      managing Time etc.

      The strange thing is that the DC Browser shows the Attributes but only some Values
      and if I click the field where the Valuse should normally be listet I get the
      error Message as attached.

      The Attribute Editor from Julia Christina Eneroth shows all Attributes and their
      corresponding Values.

      My question is how do I get a report in CSV of the attached attributes??
      A little Help would be mouch appreciated. πŸ˜•

      Thanks in Advance

      Edit: Now I know what I did wrong, In Case anyone wants to klow what it was,
      "Capitals" in the Attributes Name, now that I have written it in downcase
      Letters everything works fine. πŸ˜„


      Error-Message


      DC Browser with missing Values


      Eneroth Attribute Editor with all Attributes and Values

      posted in Dynamic Components sketchup
      JHJ
      JH
    • 1 / 1