🏢 PlaceMaker | 25% off for February including new Google Earth data imports! Learn more
  • Face material not set

    2
    0 Votes
    2 Posts
    137 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
    132 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
    373 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
    391 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
    902 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
    455 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
    146 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
    134 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.)
  • Get rotation(transformation)

    31
    0 Votes
    31 Posts
    1k Views
    jolranJ
    I finally got TIG's version going(forgot to comment out #def.self when running it in R.code.editor, amanidiot!) SOme funky thing going on when changing hatch_angle. But its stable and works in any axis. Not what can be said about "my" script. A bit unstable, until the intersectionpart. My intuition tells me doing copying edges within groups + intersection gives more predictable hatch_result when rotating hatches. But is alot more unstable when gathering and erasing? Plan A: Stop whining and get the work done so Layout-users finally have a hatch-plugin Plan B: Adjust TIG's script so it works in all angles, with menus and such. (will be difficult, since I don't totally understand it yet) PlanC: Continue to work on mine(a bit egoistic but I won't learn from copy/paste), integration as much of TIG's script as I can, thus make my script more stable if possible. However. That might not be possible, and I would have to do at least 5 different methods for views. I guess I'm asking if there is any pointers for things to avoid that make this script crash.
  • How to detect the closed body?

    6
    0 Votes
    6 Posts
    203 Views
    voljankoV
    Ok,I like this definition:If all the edges in the geometry have 2 faces ,it is a solid. Maybe I have complicated a little
  • PolygonMesh behavior

    34
    0 Votes
    34 Posts
    2k Views
    thomthomT
    @adamb said: @thomthom said: I did that for Vertex Tools, I take the average normal of the faces connected to the vertex. You're missing a step with your averaging there. You need to weight by the contribution each face connected to the vertex makes - ie weight by the interior angle otherwise a cube constructed of triangles will end up with vertex normals not all pointing out exactly at 45 degrees. How does one do that?
  • Very difficult key codes!

    10
    0 Votes
    10 Posts
    624 Views
    TIGT
    Also note that TAB on MAC only fires with onKeyUp and is ignored otherwise ! The TAB key == 9 or 15 or 48 [for PC or MAC or ??]
  • Iterator problem

    16
    0 Votes
    16 Posts
    481 Views
    Dan RathbunD
    @spireup said: Now Im just trying to get the syntax right for those inner args arrays. eg(not working) class WidgetSet < Array > end # class > > class Widget < Hash > > attr_accessor ;arg1, ;xPos, ;yPos, ;zPos, ;height, ;width, ;type > > def initialize(arg1, xPos, yPos, zPos, height, width, type) > > Hash.new["arg1", arg1, "xPos",xPos,"yPos",yPos,"height", height, "width", width,"type", type] > @arg1 = arg1 ##etc for each arg > MyWidgets < self > end It does you no good to construct an object without a reference to it (the line with Hash.new). If you want to use a Hash, then use one for your Widgets. They need not be a custom subclass, unless you need custom methods. Hashes dont need attributes (instance refs,) because they use key / value pairs, instead. my_widget_1 = { 'xPos' => 3.4, 'yPos' => 1.0, 'zPos' => 2.3, 'height' => 6.784, 'width' => 4.0, 'type' => "some_type" } There is another thread on how to save and retrieve hashes into/from an Attribute dictionary. see: http://forums.sketchucation.com/viewtopic.php?f=180&t=30066 Arguments: *list_name compacts an argument list into a local array referenced by list_name Within the method, you can access array elements using the [] method. def some_method(*args) @xPos =( args.size>0 ? args[0] ; 0.0 ) @yPos =( args.size>1 ? args[1] ; 0.0 ) # etc. end If you use 5 arguments, but a call gives more than 5, the addtional arguments will be still be stored in the local array, and no ArgumentError, will be raised. I suggest you visit the Code Snippet index: http://forums.sketchucation.com/viewtopic.php?f=180&t=28846&p=323876#p322175
  • Looping over menu item creation

    4
    0 Votes
    4 Posts
    176 Views
    P
    Thank you Jim! That did the trick! So .each method does not hold the iterator variable, but a for loop does in Ruby. Good to know. Thom, I'm only inspecting the first item that is selected. I'm hoping that doesn't load the entire selection set and cause delays. I'm a relatively novice programmer so I don't really know, but I don't see any studdering with the menu when I have a large selection.

Advertisement