ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
  • Group.copy fails

    11
    0 Votes
    11 Posts
    438 Views
    X
    @tig said: I've looked too and can't find anything... there is group.definition and various extra group methods, but none that should clash - weird or what ? Xrok1 found that with SP installed, he couldn't get group.copy to work at all it kept returning Nil ! BUT after un-installing SP it all worked OK... i even reinstalled then uninstalled SP twice to confirm. here is the offending version, i saved a copy for just such skepticism. BADSetupSketchyPhysics3x-Jun27.rar
  • Download to Sketchup button

    29
    0 Votes
    29 Posts
    4k Views
    E
    Thanks for the update. I haven't had a chance to try to implement this yet, hopefully I will in the next few days. I will certainly let you know how it all turns out!
  • 3D Engine

    3
    0 Votes
    3 Posts
    243 Views
    M
    Take a look at my 3-minute movie to see SketchUp in its full-4D glory. Then use the code in my tutorial's Chapter 16 for classes that let you do all this without need for the APIs Transformation class.
  • [help]Group component instances

    4
    0 Votes
    4 Posts
    195 Views
    M
    In addition to TIG's info, you should move all the one-time code outside the loop. model = Sketchup.active_model entities = model.active_entities path = Sketchup.find_support_file "mymodel.skp" ,"Components/" . . . I also heartily recommend that you use four-space indentation in spite of the fact that two spaces is a Ruby convention. Four is much more readable which is why it is mandatory in Python, convention in C++, Java, JavaScript, ... (every language I know, except Ruby). New languages are always a PITA. Fortunately, quite a small subset of Ruby is all you really need to create SketchUp plugins.
  • Adding Cylinders to Sketch

    4
    0 Votes
    4 Posts
    219 Views
    thomthomT
    When adding groups components programmatically you got to think somewhat different from when you model. When you model you first make the geometry and then group or make a component out of it. When you program you create the group or component first and then add the geometry directly inside it. model = Sketchup.active_model entities = model.entities # Create a series of "points", each a 3-item array containing x, y, and z. pt1 = [0, 0, 0] pt2 = [20, 0, 0] pt3 = [20, 20, 0] pt4 = [0, 20, 0] # Call methods on the Entities collection to draw stuff. new_face = entities.add_face pt1, pt2, pt3, pt4 new_face.pushpull 0.75 # Draw a circle on the ground plane around the origin. center_point = Geom;;Point3d.new(1,1,0) normal_vector = Geom;;Vector3d.new(0,0,1) radius = 0.3 # Make a new component definition comp_def = model.definitions.add("Cylinders") # Generate the geometry. Note that component definitions has and Entities collection - as model does. edgearray = comp_def.entities.add_circle(center_point, normal_vector, radius) first_edge = edgearray[0] face = first_edge.faces.select { |f| (f.outer_loop.edges & edgearray).length == edgearray.length }.first face.pushpull(3) # Now add an instance of hte component to the model transformation = Geom;;Transformation.new([2,1,0]) componentinstance = entities.add_instance(comp_def, transformation)
  • Archaeoastronomy and Sketchup II

    27
    0 Votes
    27 Posts
    3k Views
    C
    Dan, no astronomy, no calculation, no ancient dates are needed, no RA and DEC anymore. I'm using another coordinate system that uses SU horizontal plane and north. Please read this post: http://forums.sketchucation.com/viewtopic.php?f=180&t=27480&start=15#p238823 I will do all the astronomy, calendar calculations and math. Just need a script that tells a vector to rotate around blue axis given an angular measure and then raise that vector with another angular measure as I explained with the pictures in the post, and lastly align the Zaxis of a given plane to the vector. Thanks Dan and all you people that are investing their time to help. @dan rathbun said: @chris fullmer said: I think none of us want to learn how to calculate the position of the stars 8,000 years ago. Besides it cannot be done in Ruby. Standard Ruby (and Sketchup Embedded Ruby,) use the included class Time which has an initial date of January 1, 1970 CE(AD). I have tried to set Sketchup dates before this, and the app does not allow it. (In addition, the MAX year is 2037.)* The ShadowInfo['ShadowTime'] attribute takes and returns only Time class. (It actually does not not raise an Exception if you say give it an Integer, but the value will be unchanged.) This post actually began over at GoogleGroups, and there I posted some info for the requester, that if he wanted to be historically accurate, the plugin would need to ignore Sketchup's built-in Sun positioning and Time keeping. The plugin would need to keep it's own date and time (with a dialog to set them,) and the Moon (Luna) and Sun (Sol) would be treated as just stars (like all the rest.) In addition, the plugin would need to use the Ruby Extended class Date, which can go back 6723 years MAX, as the initial date is January 1, 4713 BCE (4712 BC, accounting for year 0). I would think this implies that future versions of software utilizing Ruby should move to using the Date class (and it's DateTime subclass,) sometime in the next 27 years. I did a bit of checking, I'm looking for calculation software that runs on remote web servers, so a plugin could query that server for a particuler star's RA and DEC, from a specific geolocation and date; rather than do it itself. I did find some code, at an Italian University but it's written in IPL, and would need to be translated to C or Ruby. I don't know IPL.
  • Use PickHelper to find nested Instances?

    16
    0 Votes
    16 Posts
    1k Views
    thomthomT
    So, you have a reference to a ComponentInstance_ And you want to sniff it out using the pickhelper? Maybe just some typo bug in your code?
  • Download Sketchup API in PDF ???

    5
    0 Votes
    5 Posts
    405 Views
    C
    will this work? http://www.alexschreyer.net/cad/sketchup-ruby-api-cheatsheet/
  • Importing Camera CAHV format - up and direction vectors?

    2
    0 Votes
    2 Posts
    430 Views
    J
    Chris, Have a look at the film and stage plugin - if I remember, there is some code in it which might be useful.
  • Hiding edges with fill_from_mesh

    13
    0 Votes
    13 Posts
    453 Views
    thomthomT
    That would either be using Entities.add_faces_from_mesh for each mesh - if its ok to merge them in the Entities collection. Otherwise you need to iterate one mesh and add all the polygons to the other.
  • Vector3d.linear_combination alternative form

    3
    0 Votes
    3 Posts
    153 Views
    C
    It looks like it's like it's the same as the four argument version, but works with 3 vectors at once, instead of just 2.
  • Alternate API, Pioneers Wanted

    28
    0 Votes
    28 Posts
    2k Views
    Dan RathbunD
    @jessejames said: I find the need to grab a group/comp by it's "bbox.center", "bbox.center_bottom", and "bbox.center_top" so important that i wrote a nice function to encapsulate all the calls required to retrieve these points. So maybe you would like to add this, maybe not. Let me know. It would be so nice to call obj.bounds.center('center'), obj.bounds.center('top'), or obj.bounds.center('bottom'), but that will have to wait. There is a plugin for this (that needs some language cleanup,) written by Sahi. It's called AxizComp.rb (Axis Components), see this thread (ther's some code snippets for other languages later in the thread.) http://forums.sketchucation.com/viewtopic.php?f=323&t=21635&hilit=axis#p181881 EDIT: With the release of SketchUp 2020, grips on object bounding boxes are now native ! https://help.sketchup.com/en/current-release-notes
  • Yet Another WebDialog Gotcha

    2
    0 Votes
    2 Posts
    161 Views
    J
    @martinrinehart said: Yet Another WebDialog Gotcha Seems to be annogolous with... @unknownuser said: Yet another Microsoft Windows Bug ...yes web dialogs are quite the cruel irony of SketchUp i would say. We sure could use a good ol built-in GUI about now.
  • [CExt] malloc vs ALLOC

    6
    0 Votes
    6 Posts
    365 Views
    thomthomT
    ALLOCA_N @unknownuser said: Allocates memory for n objects of c-type on the stack---this memory will be automatically freed when the function that invokes ALLOCA_N returns. Does that mean one does not need free the memory allocated by this variant? Are there times one can not rely on it?
  • Open URL on local disk

    20
    0 Votes
    20 Posts
    7k Views
    Dan RathbunD
    @martinrinehart said: I've set single click to open. An HTM opens in Chrome. Hey Martin, what's the fullpath to the Chrome executable on your PC ??
  • Untrapped Error

    5
    0 Votes
    5 Posts
    197 Views
    Dan RathbunD
    @martinrinehart said: > 64 rescue => e > 65 rslt += e.to_s().chomp() > 66 end > Your local reference e receives a pointer to an Exception object from the rescue clause, not a String object. You should use the instance method Exception.message to get the exception's string, like this: 65 rslt << e.message.chomp() (As a side-note on Optimization, generally speaking, + and += String concatenation, require Ruby to create at least one extra String object than String append <<. Ruby internally converts a+=b to a=a+b, OR a+='literal' to a=a+'literal', so using += doesn't gain you anything over <<, and may be twice as slow or more, in a loop.)
  • [CExt] C array to Ruby Array?

    4
    0 Votes
    4 Posts
    209 Views
    AdamBA
    Generally No, because the underlying representations are different. (eg Integer in Ruby is actually an integer times 4) Doubles are the exception as the representation in C and Ruby are the same IEEE format. So the values can simply be copied. However the container is another matter; in C, arrays are little more than syntactic sugar, in Ruby an Array is a real live object, so you're kinda out luck. The best you could do would be something like: extern double *reals extern int rcount; static VALUE method_getRealArray(VALUE rarray) { if (rcount < RARRAY_LEN(rarray)) { memcpy(RARRAY_PTR(rarray), reals, sizeof(double)* rcount); return Qtrue; } else { return Qfalse; } }
  • Textarea line separators on Mac

    7
    0 Votes
    7 Posts
    309 Views
    M
    @unknownuser said: I personally see no productivity or functionality gains from bothering with each platforms newline patterns, unless you just want to. This isn't the file I want given the input textarea: [image: GfrM_two.jpg] You have to convert crlf to newline because Ruby converts newline to crlf as it writes the file on a PC. Ugh. # ta_sep.rb require 'sketchup' html=" <html> <body> <textarea id='ta'>one two</textarea> <script> onload = function() { location = 'skp;go'; } </script> </body> </html>" wd = UI;;WebDialog.new( "Test", true, "test", 400, 300, 100, 100, true ) wd.set_html( html ) wd.add_action_callback( "go" ) do | dlg, msg | val = wd.get_element_value( 'ta' ) # val.gsub!( /\r\n/, "\n" ) pn = UI.savepanel( "Save As ...", File.dirname(__FILE__), 't.txt' ) file = File.new( pn, 'w' ) file.puts( val ) file.close() end wd.show() I think this is correct cross-platform code if you uncomment the gsub!(). For this I be thanking you and Notepad++ (View/Show Symbol/Show All Characters). Ruby's lovely ability to handle everything with newlines, platform-independently, does not extend to text read from a browser's textarea widgets.
  • Lock a layer

    6
    0 Votes
    6 Posts
    12k Views
    Bob JamesB
  • Python/Ruby vs. Ruby/Python

    5
    0 Votes
    5 Posts
    271 Views
    M
    Don't think I want to dust off Decaf until I've got time to go after it. I forget where I put my mains in Java. There's tons of my Java on my site: http://www.MartinRinehart.com , including the original Decaf tokenizer. There's a whole new vocabulary (words, not tokens; phrases, not expressions; sentences, not statements; etc.) that I'll need to document before anyone could realize that I wasn't just babbling. See "The Project", my site, for more.

Advertisement