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

    MichaelS

    @MichaelS

    10
    Reputation
    1
    Profile views
    7
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    MichaelS Unfollow Follow
    registered-users

    Latest posts made by MichaelS

    • RE: [Plugin] Ruby Console+ (3.0.2) – updated 30.10.2017

      Ok - found the spot:

      In "fileobserver.rb" line 71: you're using ctime to check whether the file was modified. Might be different on OSX but on Win, i need to use mtime here (ctime doesn't change if i modify the file in an external editor and save, so reload wasn't triggered).

      I changed this call to mtime and now it works.

      Michael S.

      posted in Plugins
      M
      MichaelS
    • RE: [Plugin] Ruby Console+ (3.0.2) – updated 30.10.2017

      Ok - checked again and i can't get it to work. What am i doing wrong?

      I load my script in the console with

      load "myscript.rb"
      

      As expected, the script now appears in the list of monitored scripts.
      When i edit the file in an external editor (leaving SketchUp and the console window open), save it and switch back to the console window, my changes are not recognised.
      I get an "undefined method" error if i try to add a new function to my script this way and call it from the console.
      I'm on Win7, Sketchup Make 2016, 64 bit, ae-console 3.0.2 from PluginStore

      Did i miss something?

      Grateful for any help.

      Michael S.

      posted in Plugins
      M
      MichaelS
    • RE: [Plugin] Ruby Console+ (3.0.2) – updated 30.10.2017

      Thanks Aerilius, i had suspected it should work automatic now and (thought) i had tried but it didn't work. Must have done something wrong.
      I will try again when i'm back at my computer.

      Michael S.

      posted in Plugins
      M
      MichaelS
    • RE: [Plugin] Ruby Console+ (3.0.2) – updated 30.10.2017

      Hello

      and thank you so much Aerilius for the update of my favorite tool for coding/testing scripts in SketchUp.
      Nevertheless i miss the "reload scripts" button from the previous version.
      This was very convenient and fitted my workflow so well...
      I use an external editor (Notepad++) and save the files to my plugins folder. Once loaded by typing

      load "myscript.rb"
      

      the file was automatically kept in the autoload list. After editing a script and saving the modified file, a button press brought the modified version back into Sketchup for a testrun.
      Any chance to get my button back? Please? Or is this functionality somewhere and i haven't found it yet? Of course i could write a <reload_all_my_scripts>-function and call it from the console or add an icon to a SketchUp toolbar. Just thinking this functionality fitted so well into the console (since there's still the autoload list anyway)...

      best regards,
      Michael S.

      posted in Plugins
      M
      MichaelS
    • RE: Component browser current selection?

      Ok - thanks TIG - i tried again over the weekend.
      Unfortunately i can't get it working the way i want. I think the available observers and methods are just not providing the necessary functionality.

      I can intercept the default MoveTool for a component instance contained in the model using a ToolsObserver and let my tool run instead - fine.
      I can spot when an instance was placed using a ModelObserver with onPlaceComponent and let my tool run - fine

      But i can't intercept the placement of a component before an instance was actually added to the model.
      The ToolsObserver fires when i click on a component in the components browser but doesn't provide info on the chosen definition.
      On that first click in the browser the definition is added to the model's definitionlist (only once as i stated before) and a DefinitionsObserver can spot this (once).
      The component now sticks to the mouse pointer and i can hover over the model. There's no change to the model's entities collection yet.
      The instance is placed when i click (a second time) somewhere in the model.
      Now the component instance is added to the model entities collection and at this point an Entities-Observer or Model-Observer (onPlaceComponent) can spot it.
      But this is already too late for visual feedback while placing.

      Nevertheless... keeping on sketch(up)ing 😄

      Michael S.

      posted in Developers' Forum
      M
      MichaelS
    • RE: Component browser current selection?

      Thank you for the quick response TIG.

      "Since your tool doesn't need to kick in until the instance is placed..."
      well - not exactly. Sorry, I wasn't clear enough on this.

      Actually i wanted to prevent placing the instance in the first place and - more importantly - have a visual feedback when hovering with the mouse over the model while trying to place the instance. (I really should have mentioned this in my first post...)
      My custom tool would draw a simplified "ghost" of the component using opengl functionality in the model at the mouse position (using inputpoint or pickhelper) if placing is ok.
      Otherwise i'd draw a red cross or similar indicating that placing the instance at the inputpoint is not allowed.
      A left click on a forbidden place wouldn't do anything while a left click in a place where it's ok finally inserts the component instance into the model and exit the tool.

      Your suggested method works - i tried something like this before - but gives no visual feedback while placing the instance.
      The "tool" can only remove the just placed instance if it was dropped in a forbidden place and reinvoke Sketchup.active_model.place_component to try again.

      Since i can't access the onMouseMove or draw callbacks of the builtin component placement tool, i can't have realtime visual feedback with it - therefore i intended to write my own tool.

      Michael S

      posted in Developers' Forum
      M
      MichaelS
    • Component browser current selection?

      Dear all,

      i searched but can't find a good solution to my problem - therefore my first post here. Maybe someone can point me in the right direction (if it can be done at all)?

      Consider the following szenario:
      In the component browser i have a couple of components for which i'd like to implement a custom component movement/placement tool.
      E.g. when dragging these components from the browser for placing them in the model i'd like to check clearance when moving the components around and prevent placement if the component would end up too close to some obstacle.

      My first thought was to

      1. tag these components by adding an attribute
        and
      2. install a ToolsObserver watching for the ComponentTool in its onActiveToolChanged callback (i.e. detecting the native tool when the user drags a component from the browser to place it in the model).
        Then, if the chosen component has the attribute set, i'd just call my custom placement tool (automatically canceling the native placement tool)

      The ToolsObserver fires as expected whenever i click on a component inside the component browser window, but i can't find a way to get the component definition chosen.
      I'd need this info to check for the tag and pass the definition to my own tool if appropriate.
      For the materials browser there's Sketchup.active_model.materials.current to retrieve the current selection but there's nothing similar (i know of) for the components browser.

      The ToolsObserver would have an additional benefit that extending it to do obstacle checking when moving tagged components already instantiated in the model should be fairly straightforward:
      In the ToolsObserver additionally watch for the MoveTool and call the custom move/place tool with the definition of the currently selected component instance (if tagged)...

      The only workaround alternative i can think of:
      Instead of observing tools, i could monitor the model definitions using a DefinitionsObserver. It fires an onComponentAdded when the component is selected in the browser for the first time (i.e. when its definition is added to the model) and it reports the definition as needed.
      But dragging the same component from the browser again doesn't add a new definition to the model and the observer doesn't fire ...
      So - workaround for the workaround would be:
      in the onComponentAdded callback function

      • clone the chosen original component definition without the tag (to avoid endless loop)
      • destroy the original definition so the original is added to the DefinitionList (and the observer fires) next time again
      • and place the clone by my own tool.

      Now - isn't that ugly (and a nightmare for the undostack)? You'd have to make sure these components never occur in original form at any time inside your model or otherwise the observer wouldn't work.

      So i'd really prefer sticking to a ToolsObserver if possible.
      Has anyone done something similar? Is there a "hack" or workaround to retrieve the selected component from the browser (Windows, script is for personal use, so what?) or does someone know a plugin/script i should take a look at?

      Sorry for the long text and thanks in advance!

      Michael S.

      posted in Developers' Forum
      M
      MichaelS