I have a series of spline curves defining the fuselage of an aircraft. Is there a plugin that will take a spline curve and export it into a file of x, y, z points defining the curve?
Posts
-
Export spline curves
-
RE: [Plugin] Export Cpoints to CSV v1.0 20110913
Sorry to bother you, but I got referred to this post from the newbie section. I had asked the following:
I am laying out a porous plate and was wondering if there is an easy way or perhaps a script that will read the construction points (e.g. centerpoints) of each of the circles representing the holes. If it could write out the points to a file would be great, but if it would print to the console -- I could write them down. There are a couple of hundred holes that is why I would like to automate this.
Operating system: Mac OS X
SketchUp version: V8This script sounds exactly like what I need. I placed the ruby script in the Main folder:
MacHD/Applications/Library/Application Support/Google SketchUp 8/SketchUp/plugins/but when I relaunch SketchUp I don't see the script in the Plugins pull down menu. Am I missing something?
Sincerely,
Bill -
Reading Construction Points
I am laying out a porous plate and was wondering if there is an easy way or perhaps a script that will read the construction points (e.g. centerpoints) of each of the circles representing the holes. If it could write out the points to a file would be great, but if it would print to the console -- I could write them down. There are a couple of hundred holes that is why I would like to automate this.
-
RE: Ruby script to rotate a shape using a arc
Wow! Thanks for the help and the education regarding what it takes to make it rotate a precise number of degrees. It was way past my skill level!
Thank you again.
Sincerely,
Bill -
RE: Ruby script to rotate a shape using a arc
Dear TIG,
Because what I was ultimately heading toward was the ability to take a complicated profile (Versus a rectangle) and rotate it exactly 180 degrees. The profile could be something like a cross section of a rocket launcher or a cross section of a jet engine, which wouldn't work well with the Push/Pull.
-
Ruby script to rotate a shape using a arc
Sorry to ask such an elementary question, and I hope that this is the right forum. I am working my way through ruby scripting and wanted to rotate a simple surface such as a rectangle to form half a cylinder. It is extremely important that the edges of the cylinder match up with the x-axis, so I used an arc going from 0 to 90 degrees. When the script rotates the rectangle it does something strange in that it appears to over rotate (look near the origin). The script is as follows:
# Access the Entities object model = Sketchup.active_model ents = model.entities # Create the 2-D shape curve = ents.add_curve [5, 0, 0], [15, 0, 0], [15, 0, 10], [5, 0, 10], [5, 0, 0] curve_face = ents.add_face curve # Create the arc path path = ents.add_arc [0, 0, 0], [0, 0, 1], [1, 0, 0], 5, 0.0, 180.degrees # Create the figure curve_face.followme path
and I will attach an image of what resulted. I do know that if I draw a rectangle on the x-axis and intersect with the rotated object it does line up, but why the strange behavior? Am I missing something simple?
Sincerely,
Bill
-
RE: Reading a file in Ruby
I think that I found my answer by digging into the SketchUp API documentation. Their examples show the following for the edge.start and the edge.end command. Don't know if there is a more elegant way.
edge = Sketchup.active_model.entities.add_line([0,0,0],[100,100,0])
vertex = edge.start
if (vertex)display a pointer to the Vertex
UI.messagebox vertex
else
UI.messagebox "Failure"
end
point = vertex.positionLet's get the Point3d of the vertex
if (point)
UI.messagebox point
else
UI.messagebox "Failure"
endvertex = edge.end
if (vertex)display a pointer to the Vertex
UI.messagebox vertex
else
UI.messagebox "Failure"
end
point = vertex.positionLet's get the Point3d of the vertex
if (point)
UI.messagebox point
else
UI.messagebox "Failure"
end -
RE: Reading a file in Ruby
Is there a SketchUp API command that would let you extract the beginning and end point (x,y,z) of a selected line or edge?
-
RE: Reading a file in Ruby
Dear TIG and Chris,
You both are geniuses and I can't thank you enough for your advice! I am attaching what I pieced together based on your inputs, and from info in the Ruby SketchUp programming examples. I put together a quick input file with the coordinates of a parabola just to test out the code, and it works just fine.
I am still not sure of some of the finer points of your discussion (e.g. edges versus lines), but this gets me started. Is there a good reference or tutorials for learning more about Ruby on SketchUp? I am experienced in Fortran and to a less extent C, but I can follow most of the the code. I am not sure what ".to_f" does in the loop to parse out the x,y points and would like to know more.
I will attach the simple input file in case you are interested.
First we pull in the standard API hooks.
require 'sketchup'
Show the Ruby Console at startup so we Can
see any programming errors we may make.
Sketchup.send_action "showRubyPanel:"
UI.menu("PlugIns").add_item("LinesFromFile") {
UI.messagebox("I'm about to import data")#Set your filepath by using
filepath = UI.openpanel("Open Data File", "/Users/sellers
", "*.txt")http://code.google.com/apis/sketchup/do ... #openpanel OR
hard-code it in - if you get back-slashes in your path ..\folder\file.dat
swap them for forward slashes for other ruby use filepath.tr!("\","/")
Then you open the file for reading...
lines=IO.readlines(filepath)
Now process the array of lines to get the points as x/y values
points=[]
lines.each{|line|
x=line.split(",")[0].to_f
y=line.split(",")[1].to_f
pt=[x,y]
points<< pt
}You now have an array of points.
To connect points with 'Lines' use
model=Sketchup.active_model
ents=model.active_entities0.upto(points.length-2) do |i|
ents.add_line(points[i],points[i+1])
end#do}
-
RE: Reading a file in Ruby
Just beginning with Ruby. To start off simple, all I would like to do is read in the x,y points from a file and then connect them with a line.
-
Reading a file in Ruby
I don't know if this is the right Forum to post this, but can any one tell me how to read in a file of comma separated x-y values in ruby. I am using a Mac Pro if that makes a difference.
Thanks
-
RE: Rotating a profile a precise number of degrees
Thank you all for your advice. Scaling the model up by 10 solved the problem with the nose. If you would forgive me one more question. The result posted by TIG showed rectangular faces, but when I do the lathe I get triangular faces (see attached image). For the following-on work with the CFD grid generator, I would prefer the rectangular faces. Did I chose the wrong input options (described above) on the script, or is there some way to suppress the triangularization?
-
RE: Rotating a profile a precise number of degrees
Nose region of rotated file
-
RE: Rotating a profile a precise number of degrees
Original Profile to be lathed 180 degreesThanks for the advice. I am getting close. I have attached a profile that I am trying to rotate precisely 180 degrees. When I use the extrude by lathe I do the following.
- Select the profile, which I have made into a polyline
- I type in a 0, which brings up the ability to pick an angle, then put in 180
- I type in 41s, which generates 41 sides or faces
- I double click to accept it.
The script starts working its magic making curves and faces.
- I tell it to remove co-planar edges
- I tell it to reverse the edges
- I tell it not to smooth the edges
- and finally I tell it to explode the group.
It appears to do everything correctly, however, when I examine the nose region much more closely you can see that the nose region has not been completed. It appears to be random. If I try it again, another pattern might show up. I should mention that the nose portion of the profile was generated by using a bezier curve since I need the profile to be very smooth.
Any suggestions for what I am doing wrong?
The ultimate goal of this effort is a three step process. I take the skp file and convert it to a dxf. The dxf file is read into a CAD program where all I do is convert the file to an IGES format. The final goal is to take the IGES file and input it into an unstructured grid generator for a CFD program.
-
Rotating a profile a precise number of degrees
I need to rotate a profile precisely 180 degrees. I have tried using various circles and the follow me tool, but I can't seem to get it to stop over or under rotating a few degrees.
-
Exporting Sketchup files
Does anyone know if it is possible to export a SketchUp.skp file to either an IGES, Plot3d or a d3m file? I need those file types to input the geometry into a 3D grid generator.
I have the Pro version of SketchUp, but these file types are not available.
-
RE: Extracting coordinates from a curve
Thank you Pilou and TIG,
What you both showed will do what I need. I did not know if there was a Ruby or function that will accomplish this. One other question if you don't mind. In the sample that TIG showed, some of the coordinates are preceded by a ~ sign. What does this mean?
-
Extracting coordinates from a curve
Is there a way to extract the x,y or x,y,z points off a line, curve, or bezier curve without manually trying to "digitize" points along the line?
-
RE: Pasting a Logo or Seal to a cylinder
Is there a plugin that will take rectangular faces and triangulate them?
-
RE: Pasting a Logo or Seal to a cylinder
Gentlemen,
I can't thank you all enough for your help. This is what I think is tremendous about the SketchUp community. People willing to take time out of their important day to help others learn from their experience! Rest assured that I don't typically bother posting questions until I have read, and re-read the books that I have, and the posts on the forum. Materials and textures are still one of the biggest mysteries to me.
The suggestions that you all provided were excellent and I was able to paste the logos onto the cylinder as necessary.
I hope sometime in the future someone can find out what causes the surface "crumpling" when you intersect a logo or stamp with a smooth body, and put together a work around solution. I have used that technique before to put markings on airplane models (see attached file). The intersection method was a great suggestion provided by another SketchUp expert and seemed to work well for flat, smooth bodies. When intersecting logos with rounded engines or fuselages however, the crumpling would sometimes occur. It is frustrating when it occurs because of the time spent carefully tracing over an intricate logo for intersecting with the body.
Again, many thanks for your kind comments and suggestions!