ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
  • Getting SketchUp to play nicely with RubyGems?

    24
    0 Votes
    24 Posts
    5k Views
    Dan RathbunD
    @unknownuser said: Ruby LOAD PATHs script for (Win32)](http://forums.sketchucation.com/viewtopic.php?f)":1xbd78u2] I am trying to write a plugin for sketchup 8 using rubygems. ... About the initial load error now, whenever I uncomment the #$LOAD_PATH << "#{pre}/site_ruby/#{ver}" line (the directory containing the rubygems file among others), sketchup crashes during launch. It is NOT likely you will get a standard RubyGems to work with Sketchup. One problem may be that RubyGems redefines the Kenel.require() method, which is inherited by Object, and so inherited by all other Ruby objects. For info on RubyGems, see the Resources list under the section: TECHNICAL REFERENCES It is more probable that a special version of RubyGems would be needed for use under Sketchup.
  • How do I raise a number in a loop?

    6
    0 Votes
    6 Posts
    179 Views
    Dan RathbunD
    @pixero said: Ok, that make sence. Following Jims example would it be something like: att = 0 > ary.each { |item| > item.set_attribute("Dict Name", att) > att+=1 > } 1) There's a parameter missing in set_attribute, the 3rd arg is the value argument to assign to the attribute. (Would the example assign nil, or would an ArgumentError be raised?) 2) The examples will begin at 0, not 1. (You could adjust the start ordinal for var att in it's assignment statement.) 3) Be sure the array is sorted first the way you wish to have the attributes numbered. You may need to write your own sort method if the objects in the array are complex objects, such as Drawingelement subclasses. Meaning you may wish to sort by some property of the object, such as it's height above the XY plane (just as an example.) 4) Whenever you need to iterate an enumerble Ruby object, you can use the each_with_index method (that is inherited from the "mixin" module Enumerable.) Here I add 1 to the index, so the numbering starts at 1: dict = "My Dictionary Name" val = "some value" ary.each_with_index { |item,pos| item.set_attribute( dict, pos+1, val ) } If you still wish to use 0 padded string attribute names: dict = "My Dictionary Name" val = "some value" places = 6 ary.each_with_index { |item,pos| item.set_attribute( dict, (pos+1).to_s.rjust(places,'0'), val ) } Note: The 2nd arg in rjust, the padstring, is optional and defaults to a space character.
  • Intersecting 2 Groups Question

    13
    0 Votes
    13 Posts
    316 Views
    jolranJ
    OK. thanks. I have missed the notes part.
  • BUG: WebDialog conditional comments

    4
    0 Votes
    4 Posts
    295 Views
    AdamBA
    @thomthom said: @adamb said: Rather annoyingly, if you have IE9 installed, looks like SketchUp somehow thinks its running IE7. It doesn't think - it does. Embedded web controls are handled differently. You must force it to use a different version. The thing that threw me was that SU and IE8 installed correctly reports IE8, as does IE7 and IE6 with the same html. IE9 does not. But given the conditional comments are being dropped by MS for IE10, and frankly anyone still use IE6 or IE7 is living on borrowed time, I've ripped out all the conditional stuff. thanks for the all the info though.
  • How to check registry for pro version?

    6
    0 Votes
    6 Posts
    206 Views
    M
    @jim said: TIG, what if the user installed Pro, then let it expire? Does the Pro reg key still exist? I think it might. I just tested that. It seems the registry keys get deleted if you uninstall SU Pro. I will use this to check for my program. It's not ideal, since you could probably have a pro version running as a free version, but better than nothing Thanks!
  • Strange result of a substraction

    14
    0 Votes
    14 Posts
    229 Views
    thomthomT
    http://floating-point-gui.de/
  • Face material not set

    2
    0 Votes
    2 Posts
    139 Views
    TIGT
    I'm a little uncertain what it is you are requesting A face has a face.material and face.back_material methods - these return 'nil' if there is no actual material assigned to these. There are the equivalent face.material=aaa and face.back_material=bbb - where aaa and bbb are the SUp materials or material 'names' - setting face.material=nil etc removes any material it might have, but this is unnecessary on a 'new' face as it already has 'nil' material. So if you create or 'import' new faces then by default they have no materials assigned to them. You assign materials by reference in your code to a SUp material or by-SKP-material-name (that material must be preexisting) or by-OpenGL-color-name [e.g. 'red'] (that material is auto-made if it doesn't already exist). If you are actually talking about an 'exporter' then you can find the RGB colors of the two default materials in that Style to pass on... or more simply invent two new colors within your code, so the two default materials are consistently made...
  • How to find a group?

    2
    0 Votes
    2 Posts
    136 Views
    TIGT
    Because it's working on a user's selection then all of the selected entities are in the active_entities context and you won't run the risk of a BugSplat by making a group from them directly [this is advised against usually but try it]. model=Sketchup.active_model ents=model.active_entities ss=model.selection group=ents.add_group(ss.to_a) volume=group.volume group.explode 'volume' is the volume of the selected objects in cu" if the objects don't form a solid then it'll be a negative value... Assuming that the user should have selected one group to get the volume... if ss[0] and ss[0].class==Sketchup;;Group volume=ss[0].volume if volume==0 UI.messagebox("Warning! The selected group has no volume") elsif volume<0 UI.messagebox("Warning! The select is not a 'solid' group.") end#if else UI.messagebox("Select ONE group!") return nil end#if there are many ways to achieve what you want
  • Link SketchUp with Database

    6
    0 Votes
    6 Posts
    3k Views
    AdamBA
    @jim said: For me, the easiest thing to do would be to use a WebDialog to communicate with a server where some php scripts handle the db interactions. +1 Trying to crowbar in sqlite into Sketchup Ruby is a fool's errand. Better to use a WebDialog to send & receive html requests that are processed by some web server that actually does the talking to the server DB. So decide what your html requests are going to look like (don't pollute them with sql) eg : http://foo.com?cmd=dir http://foo.com?cmd=get&sheet=ABC then write some server side code to parse those requests and do actual sql queries to squirt html back to you.
  • Webdialog stops working after action_calback

    3
    0 Votes
    3 Posts
    190 Views
    P
    here it goes (it's still a dev) 1.webdialog 1 opened with: $xdinfowindowke=UI;;WebDialog.new("xDInfo", true,"xDInfo",290,300,0,0,true) fn= $html_folder+"/xD_infowindow.html" $xdinfowindowke.set_file fn $xdinfowindowke.set_size(290,300) $xdinfowindowke.show {} 2.populated from ruby with //activated each time another SU entity is clicked command = "_sendinfo('#{$sendobjectid}','#{$sendlist}')" $xdinfowindowke.execute_script(command) 3.javascript in webdialog 1 function _sendinfo(theobjectid, theinfo){ //fill in the rows attr=theinfo.split("|||"); for (i=0;i<attr.length;i++){ splitted=attr[i].split("$$$") var oRow = oBody.insertRow(-1); //insert the first cell var oCell = oRow.insertCell(-1); oCell.className="attrnames"; oCell.innerHTML = splitted[0]+";"; //insert the second cell var oCell = oRow.insertCell(-1); oCell.className="attrnames"; //if it is the objectname, make clickable if (i==0){ oCell.innerHTML = "<a href='javascript&#058;_show4Dobject("+theobjectid+")'>"+splitted[1]+"</a>"; } else { //if the string contains ^ it means it is a link. split up if(splitted[1].indexOf("^") != -1){ waw=splitted[1].split("^"); oCell.innerHTML='<a href="'+waw[1]+'" target=_blank">'+waw[0]+'</a>'; } else { oCell.innerHTML = splitted[1]; } } } //add the end attach a last row var oRow = oBody.insertRow(-1); var oCell = oRow.insertCell(-1); oCell.height="1px"; oCell.colSpan="2"; oCell.className="split"; } This makes some html links in webdialog1 with this code: <a href='javascript&#058;_show4Dobject([i]id[/i])'>"[i]name[/i]"</a> handled by this code in webdialog1: function _show4Dobject(objectid){ query = 'skp;_show4dobjects@'+objectid; window.location.href = query; } Now back in SU this is handled by: $xdinfowindowke.add_action_callback("_show4dobjects") {|$xdinfowindowke,p| #check if the xdwindow is open--> [b]this is another window[/b] if $xdwindow visible=$xdwindow.visible? if visible==true command = "_xdhighlight('#{p}')" $xdwindow.execute_script(command) else UI.messagebox('Open the 4D Objects window to highlight') end else UI.messagebox('Open the 4D Objects window to highlight') end } Basically this all goes fine. When the html link is clicked in webdialog1, something happens in webdialog2 But from there on, when i click another SU entity the content of webdialog1 is not updated anymore. Hope the information here helps. Thx!
  • Plugin problem in SU8

    4
    0 Votes
    4 Posts
    380 Views
    sdmitchS
    Keith, I don't have a clue as to why your BoxJointTool splats but I know where it happens. I added a number of statements to print to a file then ran the program several times and in all cases it reached assentially the same place before crashing. The referenced zip file contains the output files, your modified .rb file, and my own version of a BoxJoint tool. The procedure for using mine is a little different in that instead of selecting the component then two edges, in mine, you select the component then the end face. BoxJoint files
  • Gui api in sketchup

    7
    0 Votes
    7 Posts
    1k Views
    thomthomT
    C not C++. http://www.ruby-doc.org/docs/ProgrammingRuby/html/ext_ruby.html http://www.rubyinside.com/how-to-create-a-ruby-extension-in-c-in-under-5-minutes-100.html (There is some changed needed for making it work with Ruby SketchUp. TBD got a sample project to get people started: https://github.com/TBD/OpenSUP/tree/master/SUExt The SDK TIG linked to is C++, but that is only for reading and writing .skp files - not communication with SketchUp.
  • Get an origin point inside a Dynamic Component

    4
    0 Votes
    4 Posts
    394 Views
    D
    I tested it and it is actually the good origin point which is returned by the .origin method. I need to call the method for the nested component as I decided another point for the container component's origin. And I will use a for loop to get the right subcomponent (with the right name). Thanks a lot ! Marie
  • Dynamic Component rotation through Ruby code

    3
    0 Votes
    3 Posts
    305 Views
    D
    Thank you TIG ! It works perfectly.
  • Js jquery css html Slider Panel question

    6
    0 Votes
    6 Posts
    903 Views
    Chris FullmerC
    Yup, works like a charm. Thanks! I was really hoping it was something as simple as switching "self" to "this", Chris
  • Window or crossing box selection across groups

    6
    0 Votes
    6 Posts
    456 Views
    DavidBoulderD
    So here my latest thought. Create a tool to draw a 2d rectangle on screen. Depending upon the direction of the rectangle it becomes a window or crossing box (or I have separate tools for each so direction it is drawn doesn't play a role). Then I use view.PickRay on the corners of the 2d rectangle. If I am using my rectangle as a window, I test vector from camera to each point in the model to see if it lies within the rectangle (x and y ray range test against my rectangle). If all the points of a face are pass the test that face and attached edges are in the selection (in my case I only care about faces, not edges). If any point of a face fails the test then that face is not in the selection. If I am using my rectangle as a crossing box, then I want to test each face in my model to see if it intersects with any of the four rays from my 2d triangle. If any of the four rays intersect a face, then that face is included in the selection. This doesn't address edges, which is OK for my use. If I wanted to get edges in crossing box, it would be great to convert the edge to 2d line on screen, and then see if the edge points either pass the ray range test, or interest the lines that make up the rectangle. Haven't dug into the API to see if that is even possible.) An entirely different approach (again just for faces, and in this case just window, not crossing box) would be to have the script first copy every point in the model to a loose top level point. Then I would activate the built in SketchUp selection tool. The user would make a section like they normally do. This would create an array of 3d points. I could then test the nested faces. If all of the points of a given face are in the 3d point array, then that face would be selected. I would loop through all faces, and then throw away the temporary top level points used to make the array in the first place. This solution doesn't seem nearly as clean as the first solution.
  • Inputbox Hamlet(to do or not todo)

    3
    0 Votes
    3 Posts
    142 Views
    jolranJ
    Great! That makes things a lot clearer. @unknownuser said: Avoid global $ variables that can clash with other's coding as they are accessible to everything! Thats especially the thing I was not sure about about. The last thing I wanna do is barge in here ruin everyones scripts.. Thanks a lot!
  • Ruby Hotkeys Plugin?

    26
    0 Votes
    26 Posts
    3k Views
    S
    Thank you. I will tell my friend - it's impossible. Forget about it.
  • Merge Items?

    4
    0 Votes
    4 Posts
    150 Views
    TIGT
    I moved this the Developers' Forum... Thomthom is quite right - in v8 there are lots of new tools to perform boolean operations on two solids, and tools to make them solids beforehand [if possible]...[image: OTWk_Capture.PNG]
  • SketchupExtensions Conflicts?

    3
    0 Votes
    3 Posts
    139 Views
    Dan RathbunD
    @jim said: Is it a possibility that extensions written independently by different authors inadvertently use the same Extension name? Of course they can, if they choose a simple name like "Cylinder" and do not set a version string, or everyone starts out with "1.0.0".. then yes they can conflict. Authors should use unique names, like: "Foltz: Cylinder", and use a proper version string. @unknownuser said: Would that mean that only the last loaded extension would be available? Sketchup decides whether to load (or not to load,) extensions, based upon a concatination of the name and version string. (Check the registry and you'll see what I mean.)

Advertisement