Convert sketchup files to ruby
-
Or... are you looking for how you can create geometry from scratch in Sketchup? The Sketchup API documentation have examples to how to create geometry: http://code.google.com/intl/nb/apis/sketchup/docs/index.html
-
how about any automatic tools such as 'save as' directly sketchup to ruby?
-
Just trying to clarify what you want to do: You want a ruby script which takes a 3D model and creates a ruby script which then again creates the 3D model?
-
For examples:
Something like sketchup can save as or convert to dxf (.skp to .dwf), so I want the same where sketchup save as or convert to ruby (.skp to .rb). Thanks! -
Just in case... Ruby is a program language, and SketchUP a 3D modeling program... You can't convert a sketchup file to a ruby file...
You can't convert a windows system to a Mac system, right? Same here. -
hi,I used the below progrem to get cube ,can I get program from this cube.I mean invers work
.please tell me if it possible.
many thanks
point1 = Geom::Point3d.new (0,0,0)
point2 = Geom::Point3d.new (0,0,100)
depth = 100
width = 100
model = Sketchup.active_model
entities = model.active_entities
pts = []
pts[0] = [0, 0, 0]
pts[1] = [width, 0, 0]
pts[2] = [width, depth, 0]
pts[3] = [0, depth, 0]Add the face to the entities in the model
face = entities.add_face pts
line = entities.add_line point1, point2
begin
status = face.followme line
rescue
UI.messagebox $!.message
end -
You CAN make a Ruby that'd read the geometry, groups, components etc that are in a SKP file and then save it into DATa file or within a .RB file itself. However, why would you want to do that ? If you have the SKP file you can simply import in into another SKP file using the built-in tools or with a simple Ruby...
Exactly what is it you want to do ?
-
You are nearly there - draw the face and then you don't need the 'line', simply use a 'height' value...
... height = 200 face.followme(height)
@wadhahmm said:
hi,I used the below progrem to get cube ,can I get program from this cube.I mean invers work
.please tell me if it possible.
many thanks
point1 = Geom::Point3d.new (0,0,0)
point2 = Geom::Point3d.new (0,0,100)
depth = 100
width = 100
model = Sketchup.active_model
entities = model.active_entities
pts = []
pts[0] = [0, 0, 0]
pts[1] = [width, 0, 0]
pts[2] = [width, depth, 0]
pts[3] = [0, depth, 0]Add the face to the entities in the model
face = entities.add_face pts
line = entities.add_line point1, point2
begin
status = face.followme line
rescue
UI.messagebox $!.message
end -
hi
if i use sketchup 7 for example,and I use the tools from menu and draw cube can i convert this drawing to ruby code (program)many thanks
-
No, not really. You can not reverse engineer a shape into ruby code.
-
@chris fullmer said:
No, not really. You can not reverse engineer a shape into ruby code.
Reverse engineering from a .skp into a .rb IS possible, but the programming effort required to find all of the skp's edges, faces, materials, layers, groups and components etc etc would be disproportionate compared with what you'd get. There are tools and methods available within ruby to make edges, curves, faces, pushpull, followme, add layers and materials etc etc ,that will do what you want without first making it in a skp and wrenching the info out of it.
.
-
It's possible. Exporting a model as a Ruby file is a technique I thought of when thinking about how to connect and synchronize multiple instances of SketchUp over a network connection.
-
I agree its possible to store all the entities into ruby. But I sort of get the feeling he wants an easy button that you can just click on and it will turn his shape into a script. So I was trying to be more realistic about what I am guessing he wants. But again, more info on the final purpose would be nice.
@Jim, for the script, what if it was more of something like a database that stored the entity info. And then write a ruby that would just update the model by reading the database. Is something like that feasible?
Chris
-
Hi every body
I hope you are fine.
Can you show me any example for converting sketchup to ruby coiding,
wadhah -
@chris fullmer said:
@Jim, for the script, what if it was more of something like a database that stored the entity info. And then write a ruby that would just update the model by reading the database. Is something like that feasible?
ChrisProbably "required" is a better word to use than "feasable." I haven't really thought terribly deeply about it, but I would think a database would solve numerous issues that might arise from trying to synchronize SketchUps.
-
@wadhahmm said:
Hi every body
I hope you are fine.
Can you show me any example for converting sketchup to ruby coiding,
wadhahHow do you want the code to work? You want a script that will take a model, and then store that model into a ruby script. Then what? It does no good just sitting there in ruby. What do you plan on doing with it once its stored as "ruby". Is the script supposed to be able to then re-draw that shape on another computer's sketchup?
Chris
-
To take it to its logical conclusion you extract all of the skp data into a data file... That is in effect the skp file so why have you bothered ? You could for example extract only geometry - that's something like an exporter format... Simply take all of the edges and list their start and end XYZ with ref , all of the faces and list their edges refs. Then you could take the info into a ruby to build the geometry...
-
@tig said:
To take it to its logical conclusion you extract all of the skp data into a data file... That is in effect the skp file so why have you bothered ?
That's what I've been thinking as well. I think we need some clarification on the actual purpose of the original question. I could be that the question itself isn't correct.
Advertisement