Sideview modeling

Sideview modeling

Postby gashtan » Wed Aug 20, 2008 4:12 pm

Hi all
Like a first, thanks for this forum. I`m a newbie there and I have no experiences of ruby coding (I was coding in TurboBasic and Pascal long ago :lol: )
So...my question is...is there a plugin that can make a 3D model from sideviews?
For example I have front view, left view (and top view if need) and from this 2D elements ruby create 3D model...
I think, something like this have Rhino.
In my opinion it can by so simply code, so Im thinking I create this, but... I don't know anything about coding in ruby, and I don't know if I find so much time to learn something new :lol:

0

gashtan 
 

Re: Sideview modeling

Postby Jim » Thu Aug 28, 2008 12:53 am

Hi gashtan,

It is possible to do this using Ruby. You can use the normals of the faces to get the vectors, and then look for intersections of each vertex. At the least, it should be easy enough to create a construction point grid of the object.

This sounds like fun to me, so I might try it this weekend if I get a chance.
0
Hi

Jim 
Global Moderator
 

Re: Sideview modeling

Postby MALAISE » Thu Aug 28, 2008 7:28 am

Hi Jim and Gashtan

Jim, would it be possible when writing this "plugin" to add a lot of comments
in order to understand how the script is done ?( in fact: a kind of tutorial )

Thanks for all your so useful plugins :thumb: :thumb:

MALAISE
0
La Connaissance n'a de valeur que partagée
User avatar
MALAISE 
 

Re: Sideview modeling

Postby gashtan » Thu Aug 28, 2008 12:11 pm

Jim wrote:Hi gashtan,

It is possible to do this using Ruby. You can use the normals of the faces to get the vectors, and then look for intersections of each vertex. At the least, it should be easy enough to create a construction point grid of the object.

This sounds like fun to me, so I might try it this weekend if I get a chance.


It would be greatfull if you find some free time and write this script...and then I try to understand the script :)
thanks for your answer.
0

gashtan 
 

Re: Sideview modeling

Postby Jim » Sun Aug 31, 2008 12:32 am

Malaise, gashtan,

I have some ideas on how to do it, but I'd like to hear your ideas for a strategy on how to accomplish the task.
0
Hi

Jim 
Global Moderator
 

Re: Sideview modeling

Postby gashtan » Sun Aug 31, 2008 7:17 am

Jim

my idea is very close to your:
"You can use the normals of the faces to get the vectors, and then look for intersections of each vertex. At the least, it should be easy enough to create a construction point grid of the object."
But your last sentence inspire me. It is possible to make only construction point and then joint to the shape (vertex) and finaly to the group?
Because I think it can be a problem make it in ruby like in modelling, especially in a more complex shapes.
0

gashtan 
 

Re: Sideview modeling

Postby MALAISE » Sun Aug 31, 2008 9:07 am

Hi Jim and Gashtan

@ Jim, your tutorial on SU ruby helps me really.

About projections, I would select the biggest external face, define the normal
vector and create a box using the 2 vectors of this face and the normal
one . About dimension, I would take the biggest one on each vector-direction.

Then I would project the object on faces this "outer box" and rotate axes
according space references ( Red, Green, Blue )....

( sorry for that kind of frenglish )

MALAISE
0
La Connaissance n'a de valeur que partagée
User avatar
MALAISE 
 

Re: Sideview modeling

Postby kwistenbiebel » Sun Aug 31, 2008 10:41 am

@Gashtan,

Your request is a good one.
It is actually the way I build up my architectural models from plan.
I import the elevations, facades and sections in SU as .dxf, place them into position so you get a 3D model wireframe and start 'filling in' and building up the model.
0

kwistenbiebel 
 

Re: Sideview modeling

Postby Jim » Sun Aug 31, 2008 1:36 pm

Here's the result of my first attempt. Circles and curves are not supported and I doubt a hole will show up either. But the result is not bad for a rough-in.
0
Hi

Jim 
Global Moderator
 

Re: Sideview modeling

Postby gashtan » Sun Aug 31, 2008 6:28 pm

fuu...so I thing the code can be so simply, but now I recognise my BIG mistake :D
I don't understand the half of the code, so thank you one more time to start writing the script for that...
0

gashtan 
 

Re: Sideview modeling

Postby pav_3j » Sun Aug 31, 2008 7:29 pm

wow, this is interesting, keep up the work guys!

pav
0
Just won the 'Who is Least Competitive Championships' where trying to win will make you lose. Trying to lose makes you win which makes you lose. Not trying at all makes you lose which makes you win which makes you lose.

pav_3j 
 

Re: Sideview modeling

Postby Jim » Sun Aug 31, 2008 8:03 pm

It's not hard, but I don't know how to explain it all. If you have a specific question, I will try to answer.

Here's a overview of my thought process.

Draw lines at all of the Vertices. The direction of the lines is the normal of Face that contains the Vertex. When a line intersects with at least 2 others, then you have a Point that defines a vertex of the 3D shape.

In order to find all the intersections, I have to test each line for an intersection with every other line. To do that, I need as list of all lines.

SketchUp's Geom module has a method that will tell you if 2 lines intersect, so I decided to use it instead of write my own. The method is:

Code: Select all
Geom::intersect_line_line(line1, line2)


But what is a line? There is no official Line class in SketchUp - a line is agreed to be a 2-element Array of either a Point and a Vector, or 2 Points. (See Geom module documentation.)

Code: Select all
line = [Geom::Point3d.new(0,0,0), Geom::Vector3d.new(0,0,1)]
line = [Geom::Point3d.new(0,0,0), Geom::Point3d.new(0,0,100)]


The first 2/3 of the script is all about building a list of lines in the form shown above (an Array of Arrays.)

Once the lines list is built, then we can iterate through each line and compare it to every other line for an intersection point.

Code: Select all
l = lines.length
  for i in 0..l-2
    for j in (i+1)..l-1
      pt = Geom::intersect_line_line(lines[i], lines[j])
      next if pt.nil?
      draw_cline(lines[i][0], pt)
      draw_cline(lines[j][0], pt)
      pt = pt.to_a.map{|e| round_to(e)}
      line_hash[pt] += 1
    end
  end

I use a Ruby Hash object to keep a count of the intersection points. I am not sure this is a robust way to track the intersections, but it seems to work. (The hash key is an Array of Floats. :shock: )

And once you have a list of intersection points, then you can do whatever you like with them; such as draw Contructionpoints at their positions.
0
Hi

Jim 
Global Moderator
 

Re: Sideview modeling

Postby MALAISE » Mon Sep 01, 2008 6:39 am

Hi Jim

Very interesting topic. Your explanations give us the key for
understanding Drawing process. We have now a little idea of 3D coding
using Ruby in SU.
You're welcome

MALAISE
0
La Connaissance n'a de valeur que partagée
User avatar
MALAISE 
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 



 

Return to Developers' Forum

Who is online

Users browsing this forum: No registered users and 8 guests

Visit our sponsors: