๐Ÿ’ก LightUp 7.1 | SketchUp's only real-time renderer that uses object-based rendering Download Trial
  • Pass array to a c/c++ ruby extension

    6
    0 Votes
    6 Posts
    2k Views
    Dan RathbunD

    Never could understand SWIG much. Cryptic interface language.
    If you intended to write a library that needs interfaces in multiple scripting languages, then SWIG might lessen the workload. Or if you are wanting a Ruby interface for some library already written that has SWIG interface files, then again I can see using SWIG.

    But for an extension that will be written specifically for SketchUp, since it only uses Ruby, I cannot see much use for SWIG.

    Link Preview Image SWIG - Wikipedia

    favicon

    (en.wikipedia.org)

    Link Preview Image SWIG Tutorial

    favicon

    (www.swig.org)

    Link Preview Image Simplified Wrapper and Interface Generator

    favicon

    (www.swig.org)

  • Multi-Point Tool

    2
    0 Votes
    2 Posts
    1k Views
    Dan RathbunD

    @medeek said:

    What I would like to do is make it possible to hold down the control key or some other key while selecting the point to position the footing, thereby the allowing the user to select multiple points.

    (As said also in the other forum...)

    The convention for SketchUp is that the CTRL key acts as a toggle in and out of copy mode. (This is why the API defines the constants as COPY_MODIFIER_KEY and COPY_MODIFIER_MASK.

    Examine how the SelectionTool switches in and out of add or subtract mode, and the cursor changes to show + or - satellite icons. Or the MoveTool, ... etc.

    Also see this other thread here at SCF:
    http://sketchucation.com/forums/viewtopic.php?f=180%26amp;t=67837#p621579

    You'll need to decide how to let the user tell the tool when they are done picking points.

    Another convention is that the ESC key resets the tool to it's initial state, or cancels the current state. (See the onCancel callback.)

    The ENTER is another way, detected via a onReturn or onKeyUp callback.

  • Application Development Exploding Component Instances

    16
    0 Votes
    16 Posts
    3k Views
    TNTDAVIDT

    The loading time decreased from 2 minutes to 4 seconds. ๐Ÿ‘

    Thanks Driven

  • Knowing the ComponentInstance a DimensionLinear is attached

    5
    0 Votes
    5 Posts
    1k Views
    TIGT

    Until it's fixed how about a clunky and convoluted workaround ?
    If the pa=dim.start[0].parent is a component-definition then you need to see if there is pa.instances[1] if not then the one instance is the answer.
    If there are more than one instance you need to iterate those, and assemble a list of their transformation.origin positions [ensuring the transformation steps back to match the dim's parent's and of course takes into account any instance scaling etc...] - let's call that 'pvs'.
    The pt=dim.start[0] gives you a point inside the definition.
    You have ps=dim.start[1] as the point of the dim in 3d space.
    Transform the 'pvs' inversely and compare that point with ps, if they match then you could have a hit.
    Of course two or more instances where some are rotated or flipped so that vertex is coincident in 3d returns two or more 'hit' points, so it'd not be possible to determine the attachment that way...

    So, it's better if it worked like it should !!!

  • Indigo Renderer + Sketchup plugin developer

    7
    0 Votes
    7 Posts
    3k Views
    I

    Hi all,

    we're still looking for a SketchUp developer to work on our plugin!

    Please get in touch with us at contact@indigorenderer.com if you're interested.

    Kind regards,
    The Indigo team

  • Weird DimensionLinear behavior

    5
    0 Votes
    5 Posts
    2k Views
    Dan RathbunD

    @ittayd said:

    Thanks, I'm asking about ways to interact with the text: getting, setting.

    No this is not what you asked!

    Such a simple thing (as what method's a class has) can be easily found by looking at the API dictionary.

    Link Preview Image Class: Sketchup::DimensionLinear

    The DimensionLinear class represents linear dimensions.

    favicon

    SketchUp Ruby API Documentation (ruby.sketchup.com)

    ... which is a subclass of (and therefore inherits methods from๐Ÿ˜ž
    http://ruby.sketchup.com/Sketchup/Dimension.html

    ... which is a subclass of (and therefore inherits methods from๐Ÿ˜ž
    http://ruby.sketchup.com/Sketchup/Drawingelement.html

    ... which is a subclass of (and therefore inherits methods from๐Ÿ˜ž
    http://ruby.sketchup.com/Sketchup/Entity.html

    ... which is a subclass of (and therefore inherits methods from๐Ÿ˜ž
    http://ruby-doc.org/core-2.2.4/Object.html

    You asked about dims nested inside transformed instances.

    I am not sure if the .text getter will return transformed lengths or not. Also not sure what happens when the context is open and not. So test.

    The means I showed above avoids the conversion of text ( String) into a numeric ( Length) object, and just gets the length.

  • Bounds change depending on active context?

    5
    0 Votes
    5 Posts
    2k Views
    Dan RathbunD

    @ittayd said:

    And, I wouldn't mind the coordinates changing if contains? would have acted sanely, always returning true to a point that is inside the group

    BoundingBoxes are always aligned with the model's axes. This means if you rotate a cuboid instance, it's bounding box will increase.

    The second thing you need to realize is that bounding boxes have an untransformed state (ie, the definition's entities bounds,) and each of their instances transformed bounds. The transformed bounds are not just translational, they can also be affected by the rotation and scaling of the instance.

    @ittayd said:

    I would expect the coordinates to never change no matter what entity is opened.

    As a coder, most of time when generating geometry, you are just working in the definition's local coordinates with the IDENTITY transform, (ie, everything is 1:1 and you're specifying geometry oriented in relation to the definition's local origin and axes.)

    But when the user double-clicks into an instance, that might be rotated or scaled (transparently they are actually editing the definition,) but perhaps not at the 1:1 scale.
    Imagine an instance that has been scaled 2x. The user would be drawing edges that are twice as long on the screen. So their needs to be some transforming back to the definition's scale and coordinates.

    Julia wrote a really good explanation of this recently (ie past few months.) Need to find this and give you the link.

  • Mass material importer

    14
    0 Votes
    14 Posts
    10k Views
    C

    Thanks a lot guys for the tips ! the script work fine.

    But really no one have any idea how to batch-adjust the tiling of the material ? Other ways it will take me days to manually adjust each one of them ๐Ÿ˜• (I have like 500 skm tu adjust)

  • Ruby Group Copy - Regardless of Context?

    6
    0 Votes
    6 Posts
    2k Views
    H

    Thank you Dan!

  • Flags parameter in a tool's onKeyDown/Up

    12
    0 Votes
    12 Posts
    3k Views
    Dan RathbunD

    Ah okay, 3 years and two months ago, Fredo was noticing these same issues in the following topic thread:

    onKeyDown: getting the charcater value from key

    In that thread, post # 9, I noted several other related topic threads, and the one that I just remembered by Jim Foltz, which was back in 2009.
    flags on onKeyDown?
    (Note that at this time Chris Fullmer was not yet a member of the SketchUp Team, and had not yet learned much programming.)

    See other related threads:

    My Apple Keyboard VK_KEYS

    very difficult key codes!

    keycodes intelmac

    Jim's KeyTool.rb is also posted in this topic thread, but not sure if it is the latest version ?

    Key sequence in ruby

    Now, @Anton_S posted a Windows only method that calls Windows API C functions, in this post:
    http://sketchucation.com/forums/viewtopic.php?f=180%26amp;t=57450%26amp;p=522915%26amp;hilit=keytest#p522915

    ๐Ÿค“

  • Get mac address in ruby

    8
    0 Votes
    8 Posts
    2k Views
    B

    Thanks that works

  • Axes question

    8
    0 Votes
    8 Posts
    2k Views
    PixeroP

    Thanks for the info.

  • Handling advanced selection in a tool

    4
    0 Votes
    4 Posts
    1k Views
    Dan RathbunD

    @ittayd said:

    Is there a way to utilize sketchup's own selection tool?

    The only way is to attach a SelectionObserver, activate SketchUp's native SelectTool Sketchup.active_model.select_tool(nil), collect the object references, detach the observer, and activate your tool.

    But trying to leverage native tools via code has been problematic in the past. So, this is why they finally added (SU2016) the two window pick methods to the PickHelper class.

    ThomThom wrote a tutorial and created a graphic helper chart for using this class.

    Link Preview Image PickHelper โ€” A Visual Guide

    Iโ€™ve put together a visual guide to the PickHelper class in SketchUpโ€™s Ruby API. When I first tried to use the PickHelper class I was confused over what the different methods did, and fโ€ฆ

    favicon

    Procrastinators Revolt! (www.thomthom.net)

    Other than that, you best learn by reading the example extension by the SketchUp Team (EW) or others like ThomThom's plugins.

  • Rotate a component before place it with a key imput

    2
    0 Votes
    2 Posts
    979 Views
    Dan RathbunD

    @boom02 said:

    Do you guys think this is the right way?

    NO. The spacebar is pre-coded to activate the native SelectionTool. Many users are used to it this way, and do not want to change it. Those that have changed it, have done so for their own choice of command.

    Secondly, you cannot affect how the built-in place_component works as it is a native tool, most especially not when using the repeat mode. (Ie, there really is no way to trap the spacebar and prevent it from bubbling-up to SketchUp's shortcut handler.)

    The way it is designed, when not in repeat mode, is that once placed, the normal MoveTool is active, and it's hover rotate mode can be used. Just hover the MoveTool cursor over a the side of a component's bounding box, and 4 rotate handles will appear. Move to one of the handles and you'll see the cursor change to a protractor.

    I myself, also kinda miss the ACAD spin before place feature.

    @boom02 said:

    ... how can I get the key press from the user?

    The best way is inside a custom tool class written in Ruby.
    http://ruby.sketchup.com/Sketchup/Tool.html

    And you'd need to create a menu item pointing at a method object that rotates the selected object. Then that menu command can be assigned any shortcut, by users according to their own desires.

  • Trouble adding entity to component definition

    6
    0 Votes
    6 Posts
    2k Views
    Dan RathbunD

    A workaround we employ is to stick a temporary cpoint into the entities (at it's origin,) and then delete it later after we've loaded it up with geometry. The temp cpoint stops SketchUp's garbage collector from deleting the object.

  • Importing Bulk Attribute Values from CSV

    11
    0 Votes
    11 Posts
    2k Views
    H

    BTW, the answer to the original question was that

    input = UI.inputbox(@prompts, @defaults, @list, "Select Attribute Target")

    returns an array of values because typically the inputbox would present more than 1 option. In my case there was only one input or prompt so when I put input into

    set_result = Sketchup.active_model.set_attribute("dynamic_attributes", input, att_string.to_s )

    I was actually sending in an array and thus setting a new key in the format ["whatever user put into inputbox"]. Even .to_s did not seem to help...

    set_result = Sketchup.active_model.set_attribute("dynamic_attributes", input.to_s, att_string.to_s )

    The answer was to get the first item in the array like so:

    set_result = Sketchup.active_model.set_attribute("dynamic_attributes", input[0], att_string.to_s )
  • Observers WhishList

    59
    0 Votes
    59 Posts
    110k Views
    G

    @thomthom said:

    Would that be at the event of copying? Or when pasting?
    Can you describe the scenario you'd use it in?

    when copying
    i am trying to find a way to control the difusion of dynamic components
    if such an observer would be available, it would be easy to prevent unauthorized copies
    selection observer can be used, but it is less direct, and probably less efficient than an observer on copying
    more dynamic components would be created if there was a way to crypt them, just as ruby plugins

  • Uninitialized class variable

    5
    0 Votes
    5 Posts
    915 Views
    PixeroP

    Thanks, that worked.

  • Cleaning up memory in script

    3
    0 Votes
    3 Posts
    867 Views
    PixeroP

    Thanks.

  • Replace Several Textures?

    32
    0 Votes
    32 Posts
    4k Views
    sdmitchS

    I have PM'd you a possible solution to #7

Advertisement