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

    4
    0 Votes
    4 Posts
    521 Views
    bomastudioB
    It's a new feature of SU2015 BTW?
  • Simple question: Click to create a point

    3
    0 Votes
    3 Posts
    587 Views
    B
    Thanks alot! I will give it a try.
  • Width, height and center of face?

    2
    0 Votes
    2 Posts
    526 Views
    TIGT
    In the old days there were two conventions for describing XYZ in 3d CAD. Oddly the bounding-box uses the older convention, which is not used elsewhere within SketchUp. SketchUp uses the more obvious convention, that is, as if you were looking at the 3d object in the real world 'through' the screen as if it were a 'window-frame' - X=left-right/red, Y=in-out/green and Z=up-down/blue. The other 3d CAD convention grew from 2d - it assumed you drew 'on the screen' as if looking down in plan - so bounds.width [~screen-width] is equivalent to SketchUp's X-red, and bounds.height [~screen-height] is equivalent to SketchUp's Y-green; the remaining bounds.depth is SketchUp's Z-blue - originally assumed to project in/out of the plane of the screen - to add the 3d element to a 2d plan ! A '2d' face's bounds has no 'depth' - only width and height [and center] etc Make a note of these odd naming conventions and use them accordingly.
  • Layer Transparency ?

    3
    0 Votes
    3 Posts
    494 Views
    WhyDiW
    thanks for the reply but bad news! anyone knows any make up for that, even hard? i easily deal with ruby have a good day
  • How to see the results of this method?

    8
    0 Votes
    8 Posts
    769 Views
    TIGT
    @Jim Thanks, I knew there was something somewhere - but it was six and a half years ago ! To précis a version of AdamB's [much cleverer] code: def self.face_area(mat, context, tr) area = 0.0 context.entities.grep(Sketchup;;Group).each{|e| area += self.face_area(mat, e, e.transformation) } context.entities.grep(Sketchup;;Component_Instance).each{|i| area += self.face_area(mat, i.definition, i.transformation) } context.entities.grep(Sketchup;;Face).select{|f| f.material == mat }.each{|f| normal = f.normal binormal = Geom;;Vector3d.new(normal.y, normal.z, normal.x) tangent = (normal * binormal).normalize areascale = (tr * binormal).length * (tr * tangent).length area += ( f.area * areascale ) } return area end The 'mat' must be a reference to a model.material [or nil]... The 'context' must be either the model or a group or a definition [i.e. something that will have 'entities'] The transformation 'tr' must be a 'Geom::Transformation' - even it's 'blank', so the arguments are: (material, model, Geom::Transformation.new()) (material, group, group.transformation) (material, instance.definition, instance.transformation) The method returns the area of all faces within the context, included nested containers, and adjusts them to allow for any scaling of those containers... To apply transformations of nested containers which themselves are within transformed containers etc, you need to iterate the method within itself, passing/reapplying transformations [similar to the earlier example 'sum_area' method] which I have botched in here... Note how its 'self.' assumes it's called as a method within a module.
  • Component edit window...

    2
    0 Votes
    2 Posts
    478 Views
    JQLJ
    These should be adapted to, instead of openning a temp file, open the "save as" file if one exists. Otherwise it's a fine idea.
  • Solved: how to get the ruby version?

    2
    0 Votes
    2 Posts
    748 Views
    A
    Found it... it's the RUBY_VERSION const! cheers
  • How do I change the code?

    3
    0 Votes
    3 Posts
    561 Views
    C
    TO TIG: Thank you for your reply! If I want to get the component's dynamic attributes(lenx, leny...) by multiple components collision detection? and I will deduction of the overlapping area(multiple components) after... (1)multiple components collision detection (2)get the component's dynamic attributes(lenx, leny...) Thank you for your help!
  • Using wxWidgets in extensions

    4
    0 Votes
    4 Posts
    761 Views
    T
    The most important thing is to hide all symbols when compiling wxWidgets on Mac. When fluid has done it, the crash is gone. We have same issue as with V-ray now. Thea dialogues will not close and neither refresh. It is most likely caused by using IMPLEMENT_APP_NO_MAIN(MyApp) macro in AO. This allows just a single instance of wxApp. Our solution is to create our own instance of wxApp and to use wxApp::SetIntance( instance ); instead. When SU closes I do a clean-up and call wxUninitialize(); As far as I know Thea doesn't affect any plugin, so the solution works correctly.
  • Qt4 GUI in Ruby for Sketchup plugin's

    17
    0 Votes
    17 Posts
    3k Views
    A
    I also want to use QT for user interface. Is there any examples? I decide to create thread and execute main loop of QT application in this thread. [pre:g779cno0]DWORD WINAPI mainLoop(CONST LPVOID lpParam) { coreDataStruct * data = (coreDataStruct *)lpParam; int argc = 0; char **argv = 0; data->app = new QApplication(argc, argv); data->app->setQuitOnLastWindowClosed(false); data->app->exec(); data->active = 0; ExitThread(0); } VALUE cModule_initialize(...) { if (coreData->active == 0) { HANDLE thread = CreateThread(NULL, 0, &mainLoop, (void*)coreData, 0, NULL); coreData->mainThread = thread; coreData->active = 1; return Qtrue; } return Qfalse; }[/pre:g779cno0] Thread is created in function cModule_initialize that should be executed in the begining To create window I have this function: [pre:g779cno0]VALUE cModule_createWin(...) { if (coreData->active == 0) return Qfalse; QDialog *dialog = new QDialog; dialog->show(); return Qtrue; }[/pre:g779cno0] Is that correct?
  • Flags for onMouseMove

    13
    0 Votes
    13 Posts
    1k Views
    fredo6F
    @driven said: write a test with some puts and I'll test it... john Thanks in advance. I thought initially that the question was resolved somewhere in the forum, but could not find it (and it is anyway not described in the SU API doc). Fredo
  • Start_operation and commit_operation issue

    5
    0 Votes
    5 Posts
    591 Views
    G
    Sorry, Start and commit are not nested. A few lines of debug code proves that. Still at a loss.
  • How to reload a skp as componet

    3
    0 Votes
    3 Posts
    607 Views
    W
    @jim said: Hi wikii - this topic may be of interest: http://sketchucation.com/forums/viewtopic.php?f=180%26amp;t=60568 Thank you for your suggestion, Jim.
  • Detect whether all elements of the model intersect

    10
    0 Votes
    10 Posts
    747 Views
    C
    Hello everyone I reference everyone's suggestion The successful implementation of the following code: mod = Sketchup.active_model ent = mod.entities grp = ent.grep(Sketchup::ComponentInstance) for i in 0...grp.length - 1 grp.each{ |g| next if g == grp[i] bb = Geom::BoundingBox.new.add(g.bounds.intersect(grp[i].bounds)) if bb.valid? puts "#{g.name.to_s} and #{grp[i].name.to_s} intersect" else puts "#{g.name.to_s} and #{grp[i].name.to_s} do not intersect" end bb.clear } end Next, I want to know how to calculate the model of dynamic properties of all objects (such as "Lenx", "Leny" ,"Lenz"...etc) after the object intersected the other object. The case description like this: First, detect all objects intersect situations like the above code Second, if name = "column" objects intersect name = "beam" objects(just a simple example) then, "column" objects dynamic properties("Lenx") deduction "beam" objects dynamic properties("Leny") Thank you for your advice and help [image: NS2n_01.JPG] [image: ZMDk_02.JPG]
  • How to make toolbar in method(def..end) has parameters

    9
    0 Votes
    9 Posts
    2k Views
    C
    Thanks for everybody help and advice The problem has been resolved
  • Fixed container position in html web dialog

    3
    0 Votes
    3 Posts
    473 Views
    H
    Thank you very much, it's works fine.
  • Shortcuts 2 letters

    2
    0 Votes
    2 Posts
    416 Views
    J
    One was written back in 2008 named Event Relay. It received little attention and the author last visited SketchUcation in 2009. The code for is hosted here: https://code.google.com/p/eventrelay/wiki/EventRelay Maybe the code could be updated. If this were my goal and I was using Windows, I would try to create an Autohotkey script.
  • Linear Algebra & Analytic Geometry

    4
    0 Votes
    4 Posts
    585 Views
    M
    @bomastudio said: Hi Guys, I have an agony-problem with a 3D rotation. The transform that TIG suggested (rotation) works for your need. The docs on transformations aren’t very clear, especially for people who aren’t familiar with 3D transforms or linear algebra. They’re also a little quirky, as the trans.to_a method returns a matrix that is the transpose of what I would expect. FWIW, I had a lot of linear algebra (long time ago)... Anyway, the rotation method returns a transformation based on a rotation in a plane, which is defined by the ‘axis’ parameter, which should be the normal to the plane of rotation. If the start and end vectors are parallel, they do not define a unique plane, hence, both my original ‘linear algebra’ algorithm and the rotation method fail. The code below accounts for that – Greg module SUMath def self.transVector2Vector(vStart, vEnd, pt = nil) ptRot = pt || [0,0,0] if vStart.samedirection?(vEnd) # return identity transformation, vectors are in the same direction Geom;;Transformation.new elsif vStart.parallel?(vEnd) #return 180 transformation, vStart and vEnd in opposite direction Geom;;Transformation.axes(ptRot, [-1,0,0], [0,-1,0], [0,0,-1] ) else # return rotation transform based on vStart and vEnd # vCross is normal to plane of rotation vCross = vStart.cross(vEnd) ang = vStart.angle_between(vEnd) Geom;;Transformation.rotation(ptRot, vCross, ang) end end def self.rotateFace(face, vector_end, pt = nil) # for demo purposes, the next 2 statements chose an arbitrary face # if no face passed unless face entities = Sketchup.active_model.entities faces = entities.grep(Sketchup;;Face) face = faces[0] end face_normal = face.normal t = transVector2Vector(face_normal, vector_end, pt) entities.transform_entities(t, face) # below is just for a demo confirmation sd = face.normal.samedirection?(vector_end) sVEnd = "[#{vector_end.join(",")}]" puts "face.normal.samedirection?(#{sVEnd}) = #{sd}" end end # load module thru console # type SUMath.rotateFace(nil, [0,0,1]) into console with whatever vector # you want, it can be typed as often as you'd like. # As a demo, best done with one face in the model
  • [Code] wrapping operations

    5
    0 Votes
    5 Posts
    2k Views
    M
    One can also wrap Dan's code in a method def self.operation(opName, procElse = nil, procEnsure = nil) if (block_given? && String === opName) am = Sketchup.active_model begin am.start_operation(opName, true) yield am.commit_operation rescue => e am.abort_operation puts("Error operation block #<#{e.class.name};#{e.message}.>") puts(e.backtrace) if $VERBOSE else procElse.call() if (Proc === procElse) ensure procEnsure.call() if (Proc === procEnsure) end else raise "Error operation parameters - No block given or opName not a String!" end end # call by # operation("My operation") { operation block } Note that if either procElse and procEnsure are used, they should probably be lambdas. One should also be careful about return statements in the block passed to the method. BTW, I'll use snake case for methods, maybe not variables... Greg
  • Accessing File Locations defined in Preferences from Ruby

    8
    0 Votes
    8 Posts
    926 Views
    D
    I would use something like steve suggests... %x(defaults read ~/Library/Preferences/com.sketchup.SketchUp.20#{Sketchup.version.to_i} "SketchUp.DefaultFolder.Models") BUT, it always returns the last Folder used for a Save...

Advertisement