ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
  • Include paths

    3
    0 Votes
    3 Posts
    392 Views
    Dan RathbunD
    IN Ruby you can do interpolation in double-quoted strings with the #{ } operator. The expression between the curlies is evaluated and passed to the result's to_s method, then stuffed into the string. So you'd create a string of html: html = %Q{ <html> <head> <base href="#{myroot}" /> <link rel="stylesheet" href="resources/css/webdialogs.css" /> </head> <body> </body> </html> } my_dialog.set_html(html) You can also use a HEREDOC. See: http://ruby-doc.org/core-2.0.0/doc/syntax/literals_rdoc.html
  • Tool: getMenu and toolbar

    8
    0 Votes
    8 Posts
    592 Views
    bomastudioB
    Thank you Dan. I'm going to study....
  • Simple Building Generator

    8
    0 Votes
    8 Posts
    2k Views
    R
    @unearthed said: being able to 'populate' and area quickly would be a real advantage. Would also be useful to be able to quickly show how an area could change over time say with single-floor buildings being replaced with multi-floor. Hi, I've managed to have a solution for the urban growth, however it's a pity you'd still have to growth it manually @unearthed said: Also many council GIS's are starting to to put building outlines online and this could 'build' from those... If it's not troubling you so much, could you share some websites or keywords to get those building outline? I'm sure it'll help a lot of people
  • Are there plugins for Layout?

    4
    0 Votes
    4 Posts
    952 Views
    Dan RathbunD
    FYI IMSI DoubleCAD XT was a 2D CAD application, that could be plugged into SketchUp (like Layout can be.) It ran embedded Ruby, and had a clone of SketchUp's API. It development has been discontinued, but you may still be able the download the latest version. http://www.doublecad.com/DoubleCAD/DoubleCAD-XT-v5 http://activate.imsisoft.com/doublecad.aspx?productpage=DoubleCAD_XT_v5 QCad is a low cost (~37USD) 2D application, that has Javascript API & Qt GUI toolkit for plugins. http://www.ribbonsoft.com/en/ There is a free stripped down edition you can tryout. (But it cannot really be used for work. For example trying to add a layer brings up a nag box, saying that is a Pro feature.) FreeCAD is a 2D/3D Open Source free CAD application, that uses Python for extensions and custom workbenches. http://www.freecadweb.org/ http://sourceforge.net/projects/free-cad/
  • [REQ SU api] Set component axis

    5
    0 Votes
    5 Posts
    570 Views
    kimpastroK
    @tig said: Although it's convoluted you can do it already... You use: definition.entities.transform_entities(Geom::Transformation.translation(ORIGIN.vector_to(some_other_point_in_the_context)), definition.entities.to_a) to move the origin/insertion-point of the definition. If there are any existing 'instances' you'll also need to apply an inverse transformation to them ? If the axes are rotated you can also do a ...Geom::Transformation.rotation(anchor_point, axis_vector, angle)... and again you might need to fix any existing 'instances'... Sorry bring back this post but, with this is possible to do the second move (at right)? [image: l3DH_6.png]
  • Help with loading performance using Sketchup C SDK.

    2
    0 Votes
    2 Posts
    474 Views
    Dan RathbunD
    You can also ask your question at: http://forums.sketchup.com/c/developers/sketchup-sdk The SketchUp Team members are more likely to answer, more quickly.
  • Toolbar position

    6
    0 Votes
    6 Posts
    530 Views
    bomastudioB
    A lot of things to study..... many thanks Dan....you are a GURU!!!
  • Deleting Component Instance

    5
    0 Votes
    5 Posts
    720 Views
    bomastudioB
    Guys you are and invaluable support for SU developers.... a beer to all of you!!!
  • ComponentInstance Guid question

    12
    0 Votes
    12 Posts
    1k Views
    thomthomT
    EntityID are unique for the model - but entities will be assigned a new ID each time you open it. They are not persistent. There will not be two entities with the same entityID in a model. ComponentDefinition GUIDs change as you modify the definition. ComponentInstance GUIDs persist - even if you edit the instance/definition.
  • Access specifies entity

    3
    0 Votes
    3 Posts
    415 Views
    Dan RathbunD
    # Search top and 1st nested level for a named group; grps = Sketchup.active_model.active_entities.grep(Sketchup;;Group) if !grps.empty? found = grps.find {|grp| grp.name = "Target Name" } else found = nil end if !found # found will be nil, if group was not found nested = Sketchup.active_model.entities.find_all {|ent| ent.is_a?(Sketchup;;Group) || ent.is_a?(Sketchup;;ComponentInstance) } nested.each {|ent| ents = ent.is_a?(Sketchup;;Group) ? ent.entities ; ent.definition.entities grps = ents.grep(Sketchup;;Group) found = grps.find {|grp| grp.name = "Target Name" } if !grps.empty? } end # found will be the group reference, if it was found # found will be nil, if group was not found
  • Extract 3D information to regenerate the shape

    4
    0 Votes
    4 Posts
    689 Views
    Dan RathbunD
    SketchUp is a surface modeler. Everything in SketchUp is basically made up of edges, vertices, and faces. There are no complex built-in 3D shape classes in the SketchUp Ruby API. Instead primitives are either grouped into Group class instances, or ComponentInstance class instances. (Each have a defining ComponentDefinition class instance.) These mentioned classes are all sub-classes of Entity, and inherit it's functionality (as well as the intermediate Drawingelement class functionality.) Any Entity subclass instance can have any number of AttributeDictionary instances attached to them. You can put whatever custom data you wish into attributes in a custom dictionary, usually named the same as your plugin. (Ex: "Ruts_Shaper_Properties") Back to the grouped 3D shape. Groups and components have a built-in definition name and each instance of them can have a separate more unique instance name. Group and component instances have built-in transformation property, from which you can query all the translational, rotational, scaling and axial subproperties. See the Geom::Transformation class. All Drawingelement subclasses (the objects that can be seen in the model,) have an invisible boundingbox, from which you can get the corners and the center. See the Geom::BoundingBox class. It would be more efficient to create the basic shapes as an external SKP component library, and insert them into the model, rather than draw each using code, but drawing them adhoc can be done. You should most likely install the SketchUp Team's example Shapes plugin, and study the code. http://extensions.sketchup.com/en/search/site/Shapes
  • Variable values in attribute dictionaries

    8
    0 Votes
    8 Posts
    812 Views
    Dan RathbunD
    @ssunderland said: ` n=0 i=0 Sketchup.active_model.selection[n].set_attribute("Bubble","id",i); n+=1; i+=1` You are missing some basic knowledge of Ruby. Most of the API collection classes have the library module Enumerable mixed into them. http://ruby-doc.org/core-2.0.0/Enumerable.html It is usually safer (to avoid fencepost errors, etc.) to use the built-in block form iterator methods. Sketchup.active_model.selection.each_with_index {|ent,idx| ent.set_attribute("SSU_Bubble","id",idx) } If you want to process in reverse order, make an array copy of the selection, using to_a and the Array#reverse method: Sketchup.active_model.selection.to_a.reverse.each_with_index {|ent,idx| ent.set_attribute("SSU_Bubble","id",idx) } However, there is one major rule. Do not delete collection members while iterating the collection. The loop will lose it's place, and strange results occur. In that case, always iterate an array copy of the collection, if your loop must remove or add collection members. This is most often seen while modifying Entities collections.
  • Saving all instance variables of an object

    14
    0 Votes
    14 Posts
    1k Views
    A
    Bug posted in the GitHub Issues field!
  • Change color entity group

    3
    0 Votes
    3 Posts
    511 Views
    Y
    Excelente! Thanks very much!
  • This tripped me up (again) today

    25
    0 Votes
    25 Posts
    4k Views
    A
    Back to TIG's comment about plural vs. singular names for arrays, here is the way I'm naming things. In this context, the singular terms seem to work better for me, probably because I think of it as the mathematical notation P[sub:2dctu78y]0[/sub:2dctu78y], P[sub:2dctu78y]1[/sub:2dctu78y], ... P[sub:2dctu78y]N[/sub:2dctu78y]. =begin point[N] x-------------x point[0] angle[0] = angle_between vector[N], vector[0] vector[N] \ vector[N] = point[N], point[0] \ \ vector[0] \ vector[0] = point[0], point[1] \ x point[1] angle[1] = angle_between vector[0], vector[1] / vector[1] / vector[1] = point[1], point[2] / / / x point[2] angle[2] = angle_between vector[1], vector[2] =end
  • Access module variables from inside a module class

    2
    0 Votes
    2 Posts
    307 Views
    Dan RathbunD
    "Programming Ruby - The Pragmatic Programmer's Guide" explains it all.
  • Webdialog - getting started?

    21
    0 Votes
    21 Posts
    1k Views
    thomthomT
    I tried once more, and this time it's listed. (no idea why it wasn't earlier - but at least it's working now.) Very nice feature.
  • Importing don't have to bring inherit of lenz

    2
    0 Votes
    2 Posts
    263 Views
    kimpastroK
    well.. that's embarrassing... actually the "problem" is that i had overloaded "onElementAdded" method.. and put: @service.recent_inherit! entity now i send a new attribute, then it becomes: if entity.definition.get_attribute 'dynamic_attributes', 'imported_entity' @service.recent_inherit! entity end sorry about that and thanks for your time. cheers.
  • Custom tool creating instances of text labels

    5
    0 Votes
    5 Posts
    399 Views
    S
    @tig said: Here's how I would do it... Let's first assume that a component-instance has no label. The user clicks on it. It is confirmed as a component-instance. It is also checked for a special attribute, tid=instance.get_attribute("SensorNodeInfo", "tid", nil), in this case it returns nil as it has no label. unless tid > ### add_label_code > else > ### delete_label_code > end The 'add_label_code' will make the Text object, and give it a 'tid', a matching 'tid' will also be given to the picked instance... ` tid=Time.now.to_f+rand instance.set_attribute("SensorNodeInfo", "tid", tid) some code to add the Text object - referenced as 'label' label.set_attribute("SensorNodeInfo", "tid", tid)` Now the instance and its label are pair with a matching [unique] tid attribute. The 'delete_label_code' erases any related 'label', by matching its 'tid'. The 'label' Text object will have been previously given a unique 'tid' returned in the 'instance' match that was NOT nil, so you need to iterate the instances context to get possible candidates, labels_to_go=instance.parent.entities.grep(Sketcup::Text).select{|e| e.get_attribute("SensorNodeInfo", "tid", nil)==tid } then instance.parent.entities.erase_entities(labels_to_go) if labels_to_go[0] Thanks that's very helpful.
  • Ruby access to &quot;hidden&quot; v-ray materials

    2
    0 Votes
    2 Posts
    356 Views
    dkendigD
    those don't sound like issues that were in the latest service release. The V-Ray material information is stored in the material's attribute dictionary in xml format. Multi-Materials have the child material xml included with them.

Advertisement