ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
  • Find out if point is inside solid

    13
    0 Votes
    13 Posts
    2k Views
    P
    @sdmitch said: It should if "point" is truly inside the solid. If it is a model point then it will need to be transformed by the inverse of the solid's transformation. Thanks Yes the point must be in the solid(group) coordinate space. I've changed the code a bit to allow shell (outer face) testing Here it is: Edited: After some testing still something was not OK. I realized that when the ray crosses an edge it hits 2 different planes and through a vertice it can hit an unknown number of faces. The solution I came is that the ray crosses the solid in only one point. So instead of keeping track of how many faces it hits, I register all points the ray hits the solid and then perform a uniq-like operation to the array to count the number of points/hits. I've updated the code. For the filtering uniq! doesn't work (guessing because it uses eql? and this is not implemented in Point3d) Also tried pts.uniq! {|pt| pt.to_a} but it didn't worked, but since the raycast is parallel to X axis comparing x coordinate does the trick def point_insidesolid?(point, solid, exclude_surface=false) vect = Geom;;Vector3d.new(1,0,0) pts = [] solid.entities.grep(Sketchup;;Face).each do |face| if(FaceTools.is_pointof_face?(point,face)) return true unless exclude_surface return false else pt = Geom.intersect_line_plane([point,vect], [face.vertices[0].position, face.normal]) if(!pt.nil?) if(FaceTools.is_pointof_face?(pt,face) && pt.x>point.x) pts.push pt end end end end ptsuniq = pts.uniq {|pt| pt.x} return ptsuniq.count%2!=0 end def point_insideface?(point,face) case(face.classify_point(point)) when Sketchup;;Face;;PointInside, Sketchup;;Face;;PointOnVertex, Sketchup;;Face;;PointOnEdge return true end return false end
  • Need Help adding predefined dynamic Attributes via Ruby

    5
    0 Votes
    5 Posts
    904 Views
    JHJ
    Allright, Got it partly working, But I Cant get the Attribute-Inspectors to show the Values, I guess I dont really understand how to set the Formulas correctly to get the corresponding Values by now. The DC Browser shows the Values (Lengths of the Piece in X,Y and Z) but everything else does not, this means no reporting so far. Can anybody push me a little in the right Direction Where do I have to set the DC Attributes Instance or Definition? and how could I set it to both if needed? I tried to set it to the Definition and the second time I run the Script the created Geometry has no Attributes at all, or at least nothing important. The unfinished Script, still buggy
  • [REQ] Converter format asg

    3
    0 Votes
    3 Posts
    824 Views
    pilouP
    Precision : you have just to rename the .asg in .zip unzip it for have a file .xlm
  • Pre Save Observer

    4
    0 Votes
    4 Posts
    1k Views
    J
    I'm glad it helped. What I said is true on Windows because there is ever only one Model. On a Mac you can have more than one model opened. But you still probably need to attach your observers when new models are created.
  • Drawing Nuts and Bolts

    2
    0 Votes
    2 Posts
    614 Views
    gillesG
    http://sketchucation.com/forums/viewtopic.php?f=323%26amp;t=40172
  • How to create a hole in a surface?

    13
    0 Votes
    13 Posts
    2k Views
    T
    @unknownuser said: I have no idea how you determine what @ptw1616 is but another option might be creating an array of the locations like this All the points are per-determined in my script. They relate to the user selected area. Various combination of points make a pattern of lights the user can choose from in the Light Array Type Dialog Box. Your understanding of Ruby has helped me tremendously. Furthermore I did not realize the importance of the last "}" .....which I originally thought might have been a typo........ Yikes!!!
  • A ruby code to display dynamic component

    7
    0 Votes
    7 Posts
    1k Views
    G
    i have to work to understand what you wrote, observers a re new for me thank you @dan rathbun said: Taking John's example cross-platform: > class MyModelObserver < Sketchup;;ModelObserver > > # ! If the DC extension is ever changed, this example could break ! > > def onPlaceComponent(instance) > return nil unless defined?($dc_observers) > # check if it's a DC in here; > if instance.attribute_dictionaries && > instance.attribute_dictionaries['dynamic_attributes'] > # then set Selection Tool and trigger the dialog; > Sketchup.active_model.select_tool(nil) > dc_class = $dc_observers.get_latest_class > if dc_class.configure_dialog_is_visible > dc_class.get_configure_dialog.bring_to_front > else > dc_class.show_configure_dialog > end > dc_class.refresh_configure_dialog > end > end > > end > This code is fragile, because it deals with someone's else's extension. They could change it (such as method names,) at any time in the future and this example will break.
  • Aligning face normal to an edge

    2
    0 Votes
    2 Posts
    562 Views
    Dan RathbunD
    You will need to create the face within the entities context of a group or component, as only they can be transformed. EDIT: Actually Whaat might have a better idea, here: http://forums.sketchup.com/t/i-want-to-align-face-normal-to-an-edge/35033/2
  • Followme with the SketchUp API

    8
    0 Votes
    8 Posts
    926 Views
    sdmitchS
    Or perhaps top_face = entitiestb1.add_face(topcircle) top_face.reverse! if top_face.normal.samedirection?(topbaredges[0].line[1] status_top_bar = top_face.followme(topbaredges)
  • Extension Signing

    30
    0 Votes
    30 Posts
    4k Views
    medeekM
    Its working great now, I'm using Chrome as my browser and zipping the files with Windows 7.
  • How to display sketchup file on website like my.sketchup.com

    7
    0 Votes
    7 Posts
    5k Views
    G
    @dan rathbun said: @Gábor: I think they meant DAE format. Yes, thank you for the correction. I could imagine a server-side software pack what does convert the .skp at server-side to a webgl digestible format and creates the html for it. But it won't be a free solution for sure. Exporting the file at client-side to a format what already has ready made webgl loader or using an include of an already existing web viewer is probably the most cost-effective for small firms. Though a little bit more labor intensive than a ready-made custom tailored server-side pack. May I ask the original poster why is it so important to host it on their own server?
  • SKUI — A GUI Framework for SketchUp

    75
    0 Votes
    75 Posts
    13k Views
    EvanE
    Dan, right on the money. I have been programming for 53 years but I am new to Ruby. I have done JS/CSS work but not a lot. Assembler is my game and that is where I am very comfortable.
  • Adding layers to extension

    10
    0 Votes
    10 Posts
    1k Views
    Dan RathbunD
    @medeek said: Are there any more gotchas I should be aware of with layers? Yes, SketchUp layers are not really layers at all. They do not "own" geometric collections of entities (like they do in most CAD applications.) In SketchUp, layers are display behavior property sheets, that can be shared with multiple entities. So in SketchUp, each object descended from Sketchup::Drawingelement has a layer property that can be assigned to point at one of these property sheets (that were misnamed "layers" by the developers.) So, in reality you assign a SketchUp object to "use" a layer, not put an object upon a layer. @paul russam said: ... could you please precede your layers with your/your plugin name this way they will remain unique, ... If you did the same with any component and material names your plugin(s) creates it would be very helpful too. This also applies to Attribute Dictionary names. They should be prefixed with the name of your author name and extension name in some way, so there will not be any clashing of dictionary names. (For example, we all cannot have dictionaries named "Properties".) Something like "Medeek_TrussMaker_TrussProperties" or whatever.
  • [Code] Skew Transformation from axes

    21
    0 Votes
    21 Posts
    4k Views
    thomthomT
    No sure where it would fit in the docs. Maybe we can add a Wiki section on the GitHub repo that host the new docs. This scenario is so common though that a face.coplanar_with?(other_face) might be a nice addition.
  • Custom Dynamic Component Functions = Ruby links

    30
    0 Votes
    30 Posts
    12k Views
    halroachH
    Seems like the site is back up and running! The link about "Adding Functions" seems to have changed to this: http://cfcl.com/twiki/bin/view/Projects/SketchUp/Cookbook/DA_Adding_Functions
  • How to list all Sketchup.send_action?

    9
    0 Votes
    9 Posts
    895 Views
    Dan RathbunD
    I can get some command ID numbers from menu items and buttons etc. by using a resource inspector utility. Currently I am using one named "Inspect Object" that comes with Microsoft Windows SDK, that can inspect GUI objects in realtime of all running applications. P.S. - command ID integers only work on the Windows platform.
  • Windows spawn program

    3
    0 Votes
    3 Posts
    536 Views
    G
    Of course !! Thanks Tig
  • Kernel.system asynchronous on OSX?

    4
    0 Votes
    4 Posts
    571 Views
    Dan RathbunD
    I usually use a timer in this scenario, to check when the file exists, then cancel the timer and call the post processing method. @tid = UI;;start_timer(0.5,true) { if File.exist?(@filepath) UI;;stop_timer(@tid) post_process(@filepath) end } EDIT(Add): Also, I would usually have a counter variable that gets incremented each timer loop, and a max number of trys, if the file never becomes "ready" then I also exit the timer and somehow display a warning or message that things did not work.
  • Setting up camera/scene using Ruby

    4
    0 Votes
    4 Posts
    768 Views
    thomthomT
    SU's FOV is by default the vertical (height) axes. Which is something that always tripped me up. Use the camera.fov_is_heigh? to determin if fov is vertical or horizontal: http://ruby.sketchup.com/Sketchup/Camera.html#fov_is_height%3F-instance_method You might have to take into account the aspect ratio of the SU viewport and your target viewport.
  • 2017: webdialog changes

    10
    0 Votes
    10 Posts
    1k Views
    K
    @thomthom said: Can you share this example? I can forward it internally for investigation. Sure. I also posted it yesterday on the Trimble forum and a fix was suggested by sage John (add autofocus to the input textbox in html). Haven't had time to test it thoroughly though. See more here: http://forums.sketchup.com/t/html-dialog-speed/33832/7

Advertisement