Sketchucation Tools 5.0.7 | Licensing improvements and bug fixes Learn More

Subcategories

  • No decscription available

    20 Topics
    462 Posts
    HornOxxH
    @pilou said: More appetizing in chocolate! Eggs are good as well - but only very fragile when falling down in SketchyPhysics
  • ComponentInstance Guid question

    12
    0 Votes
    12 Posts
    2k 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
    538 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
    882 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
    1k 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
    2k Views
    A
    Bug posted in the GitHub Issues field!
  • Change color entity group

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

    25
    0 Votes
    25 Posts
    5k 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
    433 Views
    Dan RathbunD
    "Programming Ruby - The Pragmatic Programmer's Guide" explains it all.
  • Webdialog - getting started?

    21
    0 Votes
    21 Posts
    2k 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
    360 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
    594 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 "hidden" v-ray materials

    2
    0 Votes
    2 Posts
    445 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.
  • I wish to hire a developer

    10
    0 Votes
    10 Posts
    1k Views
    dkendigD
    I know I'm late to the game, but I am just seeing this now. I am wrapping up development of another extension, and will be ready to take up my next project soon. Are you still looking for a developer to make this for you?
  • Need to hire developer for extension creation

    2
    0 Votes
    2 Posts
    518 Views
    dkendigD
    I'm wrapping up development on another plugin, and will be available for my next project soon. Are you still looking for a developer to help you create this?
  • Which folders does SU look for gems in?

    3
    0 Votes
    3 Posts
    776 Views
    S
    Thanks, I will test this and come back to post the results.
  • Ruby code for selecting Component Instances by name

    3
    0 Votes
    3 Posts
    906 Views
    M
    Many thanks TIG, your first code line does perfectly the job. In fact I have many instances of the same component, and each one is differentiated by a unique name. And just by removing s.clear I can make multiple selections, which is exactly what I intended to do. You made my day !!
  • Move a Transformation.rotation object to x, y and z position

    7
    0 Votes
    7 Posts
    783 Views
    kimpastroK
    @dan rathbun said: @kimpastro said: PS: don't know if i'm using the correct terms for elements like: model, entity, modules, etc. Sorry about that. Yes you are misusing the term module. In your examples, "loaded_module" is a "loaded_component_definition". module is a ruby keyword, and a block of code that forms a namespace. Thanks, I'll be careful next time. I'm confusing about module because we use the same term to determine the "master entity" of our projects to our clients.
  • Get X,Y,Z of active_model with Ruby

    5
    0 Votes
    5 Posts
    666 Views
    thomthomT
    @dan rathbun said: The origin of the active_model is [0,0,0], which is referenced as ORIGIN. If the model came from Google Earth, then the real world co-ordinates (in inches) will be in the GeoReference attribute dictionary. > mdl = Sketchup;;active_model > if mdl.georeferenced? && > !mdl.attribute_dictionary('GeoReference',false).nil? > [ > mdl.get_attribute('GeoReference', 'ModelTranslationX', 0.0), > mdl.get_attribute('GeoReference', 'ModelTranslationY', 0.0), > mdl.get_attribute('GeoReference', 'ModelTranslationZ', 0.0) > ] > else > ORIGIN.to_a > end > Or Model.point_to_utm http://www.sketchup.com/intl/en/developer/docs/ourdoc/model#point_to_utm
  • Move group to left corner of screen

    11
    0 Votes
    11 Posts
    1k Views
    S
    Wow! This is awesome! It works! Thanks a lot. I almost gave up! Good to know, that there are real experts in this forum who are willing to help. Thanks again.
  • Install gem with dependencies on SU2014+

    5
    0 Votes
    5 Posts
    832 Views
    S
    if anyone is interested I found a solution without editing any files, using the instance_variable_set methods. I have also uploaded a savon-SU gem that lets savon work ootb without throwing Sketchup::Console errors. Gem;;Platform.local.instance_variable_set(;@cpu,'x86') x86 Gem;;Platform.local.instance_variable_set(;@os,'mingw32') mingw32 Gem;;Platform.local #<Gem;;Platform;0x473bf20 @cpu="x86", @os="mingw32", @version=nil> Gem.install 'savon-SU' [#<Gem;;Specification;0x5448888 nori-2.6.0>, [#<Gem;;Specification;0x92b9a94 mini_portile-0.6.2>, #<Gem;;Specification;0x3bc3010 nokogiri-1.6.6.2-x86-mingw32>], #<Gem;;Specification;0x5a70410 wasabi-3.5.0>, #<Gem;;Specification;0x4685dfc builder-3.2.2>, #<Gem;;Specification;0x4fb40a4 gyoku-1.3.1>, #<Gem;;Specification;0x512df18 akami-1.3.1>, #<Gem;;Specification;0x3ce9f88 savon-SU-2.11.1>] require 'savon' true client = Savon.client(wsdl; "http://www.w3schools.com/webservices/tempconvert.asmx?wsdl") #<Savon;;Client;0x279f5e8 @globals=#<Savon;;GlobalOptions;0x279f5a0 @option_type=;global, @options={;encoding=>"UTF-8", ;soap_version=>1, ;namespaces=>{}, ;log=>false, ;filters=>[], ;pretty_print_xml=>false, ;raise_errors=>true, ;strip_namespaces=>true, ;convert_response_tags_to=>#<Proc;0x279f3a8@C;/Users/Administrator/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Gems/gems/savon-SU-2.11.1/lib/savon/options.rb;85 (lambda)>, ;convert_attributes_to=>#<Proc;0x279f348@C;/Users/Administrator/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Gems/gems/savon-SU-2.11.1/lib/savon/options.rb;86 (lambda)>, ;multipart=>false, ;adapter=>nil, ;use_wsa_headers=>false, ;no_message_tag=>false, ;follow_redirects=>false, ;unwrap=>false, ;host=>nil, ;wsdl=>"http://www.w3schools.com/webservices/tempconvert.asmx?wsdl"}>, @wsdl=#<Wasabi;;Document;0x279e8b0 @document="http://www.w3schools.com/webservices/tempconvert.asmx?wsdl", @adapter=nil, @request=#<HTTPI;;Request;0x279e7c0 @follow_redirect=false>>>

Advertisement