Yup , my fault.
I've corrected it. there should be delauney3.rb as it uses that ruby for triangulation. Triangulation name is Delauney Triangulation.
Matt
Posts
-
RE: [PLUGIN] Voronoi + Conic Curve
-
RE: [PLUGIN] Voronoi + Conic Curve
For me it is for a interior decoration purposes.
Like a wall panel ,or sort of sculpture.
Matt -
[PLUGIN] Voronoi + Conic Curve
UPDATE
Rubies modified according to ThomThom quideline
UPDATE 2
VoronoiXY updated - code adjusted
Hello everybody.A bit time ago there was an interesting challenge posted on this forums:
http://forums.sketchucation.com/viewtopic.php?f=323%26amp;t=28521
I was interested in it , because I want to make something like that for myself. Well maybe a bit smaller.
Workflow is clearly stated in that discusion, but two problems onderway were not so easy to solve:- genereating Voronoi diagram from points cloud (as many people struggle with Qhull plugin)
- Creating nice cutouts in those cells,
So here we go :
Voronoi - At this time it is limited to XY plane, but in a code I have put remarks what have to be adjusted (it is not tested, if it is all You have to change). My algorythm uses delauney3.rb , and is based on code of Tig's triangulation.
In fact TIG's plugin can create delauney triangulation also for nonplanar set of points, but my voronoi plugin operates on a plane.here are base points and result of delauney triangulation
What we also want to know is convex hull of those points, as that will be limit of our voronoi diagram, here You can see convex hull and combined convexhull and delauney triangulation.
And result is a Voronoi diagram for base points. Every Voronoi cell is put in a Group.I have put delauney triangulation under voronoi so You can see dependences between those two.
Operation:- Select cpoints
- Menu plugin / VoronoiXY
Next step is creating oval cutouts based on a cells.
For those I used Rational Bezier Curves.
http://en.wikipedia.org/wiki/B%C3%A9zier_curve#Rational_B.C3.A9zier_curves
After executing plugin You can use TAB to change 3 parameters.- offset - if You want to leave some material on the edge of cell
- Points- number of points that create every segment of a curve
- Weight - it controls how round / pointed curve You get
Every curve is put in a group.
I think dat pictures will explain everything:
One remark, because offset produces sometimes intersecting polygon, result of coniccurve can also intersect itself:
Operation:
- Menu Plugins/ Conic Curve in Face
- TAB to set parameters
- Click Face
Feel free to play with it.It is intended for non comertial use.
If You decide to change something / improve it - please report here what have You done, so others can also use improved version.Greets Matt[mod=:1sotkqmg]%(#FF0000)[PLEASE GET/USE THE LATEST VERSION...
FROM THE PluginStore][/mod:1sotkqmg]
Create closed rational Bezier spline based on a face vertices
-
RE: Strange,why cant I render more than 600 x 800??
Hi ,
I don't know if it will help You, but try this:- override materials and render
- save LC and IR maps
- uncheck override materials, switch LC and IR mode to from file
- render
Hope it helps.Cause of this problem is a mistery to me
Matt -
RE: V-Ray render stays black
Hi, if You are uuing physical camera check Your ISO / Aperture / Shutter time.
Maybe You don't have enough light in Your model if You are using combination of ISO 100, Aperture 8 and Shutter 1/200 ( standard settings ?)
Hope this helps
Matt -
RE: Draw 3D arc point to point
Hi , I see it like that:
- Assume that You select curve, that means you can calculate distance from beginning to every vertex , lets call it "di" for i-vertex. Total length of a curve will be "L"
- Start vertex stays in his place and end vertex will be moved with a distance "z" up
- Every vertex in between will move up by a value "dz" where dz=z*di/L
This will give you linear slope, for other possibilities (expotential, etc. ) dz will be calculated with another equation
Maybe someone can write a simple plugin ?
Matt
-
RE: How to get from 3D model to 2D construction plans?
Hi MichelC
I think I could help.
I am busy with creating tools to make paper scale models in Sketchup.
You can see examples how my scripts work here: http://www.screenr.com/user/SketchupPP
In fact it covers quite a lot of what you are asking for.One thing that is missing is a nesting algorithm, but it is very complex story.
Greets
Matt -
RE: Pause/ Hold script for extra user input
Ok, solved it in another way.
Thanks anyway.
Matt -
RE: Pause/ Hold script for extra user input
I was not precise, After messagebox there is a call for function that uses two groups and two points as an arguments. And it returns error in ruby console.
Thanks for a tip. I was thinking about something like that.
But then another questions arise:
Lets say that my basic tool is Slot, and tool that will be used for picking points up will be Pointpicker. Lets say that point1 and point2 can be stored in an array : [p1,p2]
Q1 - what should be the callout? [p1,p2]=Sketchup.active_model.select_tool Pointpicker.new
Q2 - when the Pointpicker tool will be called from within Slot tool, will Slot tool be deactivated ? And after 2 points will be picked with the Pointpicker tool, how will it know that it should go to the Slot tool to specific line ?Thanks in advance.
Matt -
Pause/ Hold script for extra user input
Hello,
Is it possible to hold script until user performs specific action ?I have a situation like this:
- 2 groups that consist from one face each,
- script is activated, user clicks first group and then second group,
- script checks for intersection between those two, sometimes intersection is not found, then useg gets MB if he wants to pick two points that will define an intersection line(p1, p2).
Problem: After user clicks YES, script continues and then crashes because points p1 and p2 were not clicked.
I apprecciate any sugestions
Matt -
RE: Tool for laying groups/components flat for laser cutting?
Hi
Here is another WIP code this time wrapped up as a plugin. Still it works only for groups.
Running: Select entities first, then use menu Plugins/SPP to execute plugin, click with a left mouse button on a screen. Observe status balk messages.
How it works:
Plugin works in 4 steps.- It will search for all groups in a selection and make every group unique
- In every group it searches for a biggest face, and then rotates whole group so normal vector of biggest face is pointed up (0,0,1)
- Then the angle between X axis and main centroidal axis of this face is found, and group is rotated one more time, to match orientation along X axis.
- Last step is placing oriented groups along Y axis, with a separation between groups ( bounding boxes ) of 1 inch. ( to change it look for separation=1 in a script and change it there, I will code another way to do it later).
Calculation based on :
http://en.wikipedia.org/wiki/Polygon_area#Area_and_centroid
http://en.wikipedia.org/wiki/Second_moment_of_area#Any_cross_section_defined_as_polygon
Therefore it works nicely for a faces without inner holes. For a faces with holes it gives a slight incorrect result in step 3.
This plugin is a part of a bigger toolset that I am making to use Sketchup for making paper models ( SPP stands for Sketchup-Paper-Planes), more will surface in a near future.
Greets
Matt
-
RE: Tool for laying groups/components flat for laser cutting?
I have looked at nesting problem before, for a purpose of placing card model parts on A4 (A3) sheets.
But it is very complicated. I based my observations on bounding boxes (BB).
I can write supplement for this script that will place all groups from point (0, 0) along x axis with a distance of (n) between bounding boxes.
I can even code it so when first line of groups reaches specified border value, it will place next row above firs row (moved in y direction).
But this is definitely not an optimal nesting algorithm.Other problem is that bounding box of a group is not always optimally aligned with a part ( e.g. part is along diagonal of BB rectangle )
Solution is to rotate group so it spans along x or y axis, explode and regroup, new BB will match group better.
You can rotate groups manually, but if you have lots of them...
My idea was to use biggest face of every group (it is already used for facing up groups) ,and to find its main centroidal axis ( axis for which you get maximal and minimal moment of inertia β in other words points of a face are so close possible to one axis and so far possible from another), and angle between main axis and local X axis.
One piece of this puzzle is to get face vertices in order (clockwize of anticlockwise ). Does face.vertices works like that ? (Can't check it right now)
UPDATE Yes it works. face.vertices reports vertices in order.This is enough to calculate second moment of area and from there angle of rotation.As for working with components... I haven't used components yet in my scripts, so have no idea is it different than using groups.
Greets Matt
-
RE: Tool for laying groups/components flat for laser cutting?
Hi
You can try this code, it is a WIP so works only for groups.It looks for a biggest face in group and rotate group so this face is up ( vector z+) and then it moves it to XY plane.
Select groups and run code:mod = Sketchup.active_model # Open model ent = mod.entities.to_a # All entities in model sel = mod.selection # Current selection groups=[] ent.each do |e| if e.is_a? Sketchup;;Group e.make_unique; groups<<e; end end big=[] groups.each do |g| #UI.messagebox g area=0 #UI.messagebox area grent=[] grent=g.entities.to_a name=g.name g.explode g = Sketchup.active_model.entities.add_group(grent) g.name= name grent.each do |e| if e.is_a? Sketchup;;Face if e.area>area #UI.messagebox e area =e.area; big<<e; end end end #UI.messagebox big.last #UI.messagebox big.last.normal if big.last.normal.cross([0,0,1]) != [0,0,0] g.transform! Geom;;Transformation.rotation(big.last.vertices[0],big.last.normal.cross([0,0,1]),big.last.normal.angle_between([0,0,1])) end name=g.name g.explode h = Sketchup.active_model.entities.add_group(grent) h.name= name vector=[] vector = Geom;;Vector3d.new 0,0,-h.transformation.to_a[14] #UI.messagebox vector h.transform! Geom;;Transformation.translation(vector) vector=[] end
Greets
Matt -
RE: Unfolding plugin idea
[Solved] BUT ideas are appreciated I am busy with reworking the code , but I found a small problem.
First situation:
Rectangle in XY plane, with a normal vector shown.
Then this rectangle was split with a line into two triangles, again with shown normals.
No problem.
Second situation, with rectangle not in XY plane:
As you can see, there are smaal differences in coordinates.
But when checking if faces are coplanar ( by comparing normals, of planes of faces) it gives a false result.
Is there a walkaround? is it possible to perform some kind of rounding of coordinates?Thanks for help.
Matt -
RE: Unfolding plugin idea
Hello
First, it is not finished, there are some things that I would like to change but have no time at this moment.
Second, it is not well tested, I know that on some conditions it will not work properly, I am still investigating the reasons.
Third, When it comes to large curved surfaces, that consist of more than 400 faces, because if the loops that sit in code it can freeze.So no official plugin yet.Still lots of things to improve.
Matt
-
RE: Unfolding plugin idea
Hello Everybody
Here is result of my work.
Plugin will make a autounfold submenu , with 2 options: unroll and rotate to XY plane AND unroll and leave in plane of last element.
Select elements to unroll first and then activate tool.
Pick first face, and then pick one adjacent to define in which direction it schould be unfolded.Script is based on idea of unfoldtool , and made with help of this comunity.
Therefore no rights reserved, and no responsibilities to be taken by author.
Feel free to test,use and modify.
C&C welcome!Matt
-
RE: Unfolding plugin idea
Thanks Everybody ! With Your help I got it working.
After this long weekend I will post what I have done.
Still there are some problems, but those I will try to solve later.Matt
-
RE: Unfolding plugin idea
I have seen Waybe, but I haven't really tried it yet.
Other thing is that it is not free, not as much of a problem if you are a hobbyist, but for commercial use? Quite pricey. So is it possible to do most of what Waybe do for free? I hope so
In a meantime ...I base my work mostly on unfold plugin by Jim. So I try to reverse engineer structure of the code.
But the problems arise. Idea is that to run my plugin I need 3 selections : basis selection of faces that will be unfolded, and 2 faces that will specify unfolding direction.
Basis selection is not a problem, because I can select it before running code.
But I need to be able to select 2 faces when prompted.
I know that I should use onLButtonDown, but I miss something and it does not work. Can anyone help ?Code:
module Autounfold # Plugin require elements that we want to unfold to be selected before running def Autounfold.main model = Sketchup.active_model model.start_operation "Autounfold" sel = model.selection bas_sel = [] face1 = [] face2 = [] Sketchup.active_model.selection.each do |e| #we define basis selection of faces to unroll if e.is_a? Sketchup;;Face bas_sel<<e; end end Sketchup.active_model.selection.clear #clear selection before asking for faces that defines direction of unrolling UI.messagebox "#{bas_sel.length} faces selected to unrolling " # information, can be ommited UI.messagebox "select first face"; # here I want to be able to select one face, and set it as face1 array UI.messagebox "select second face"; # here I want to be able to select one face, and set it as face2 array if face.length !=0 and face2.length!=0 UI.messagebox "ready to unrol"; end #here goes full algorythm end def onLButtonDown(flags, x, y, view) ph = Sketchup.active_model.active_view.pick_helper ph.do_pick x, y ref = ph.best_picked if ref.nil? puts "ref.nil" Sketchup.active_model.selection.clear Sketchup.set_status_text "Unfold; Selection cleared. Select face to unfold." return end if( ref.typename == "Face" ) if face1.length == 0 face1<<ref; UI.messagebox "face selected" return else if face2.length == 0 face2<<ref; UI.messagebox "face selected" return end end end Sketchup.active_model.commit_operation end end plug_menu=UI.menu("Plugins") plug_menu.add_item ("Autounfold"){Autounfold.main}
Thanks in advance, Matt
-
RE: Unfolding plugin idea
kyyu - Thanks a lot, somehow I missed this one.
Work continues... -
RE: Unfolding plugin idea
So I chewed TIG's reply over , and I got to work.
Result is this:[flash=425,344:oyqeq35r]http://www.youtube.com/v/vAAt2Jb9P4Y&hl=fr&fs=1[/flash:oyqeq35r]I can call it from Ruby editor, but how to wrap it up to a plugin state ??
Where can I find any tutorial or help ?