[Plugin] PLY Importer

[Plugin] PLY Importer

Postby Jim » Mon Jan 04, 2010 2:05 pm

Jim
Mar, 2014. My .ply plugin has been adopted by SketchUp, and the code is being hosted on Github. It should soon be available in the Extensions Warehouse.

In the meantime, my original version can be downloaded here.

jf_ply_importer.rb



Mar 28, 2014 - v1.0.0
  • Release v1.0.0 in order to establish a release version reference point.

This exteniosn imports ASCII.ply files

This importer handles only vertices and faces.

Here's a model repository of .ply files -

Here are a few more .ply files.

Google search for ASCII .ply files.

Some .ply files are huge, and both the import and the resulting model may bring SketchUp to a "white screen" state.

For SketchUp 7+
0
Last edited by Jim on Wed Dec 08, 2010 1:44 am, edited 4 times in total.
Hi

Jim 
Global Moderator
 

Re: [plugin] ply.rb - simple .ply file importer

Postby thomthom » Mon Jan 04, 2010 2:27 pm

Jim wrote:Some .ply files are huge, and both the import and the resulting model may bring SketchUp to a "white screen" state.

Performance is greatly improved if you create a PolygonMesh and use Entities.fill_from_mesh.
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [plugin] ply.rb - simple .ply file importer

Postby Jim » Mon Jan 04, 2010 2:32 pm

I need another me.
0
Hi

Jim 
Global Moderator
 

Re: [plugin] ply.rb - simple .ply file importer

Postby thomthom » Mon Jan 04, 2010 2:39 pm

jim2 = jim.clone
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [plugin] ply.rb - simple .ply file importer

Postby Jim » Mon Jan 04, 2010 2:48 pm

Ok, new version posted - uses PolygonMesh.
0
Hi

Jim 
Global Moderator
 

Re: [plugin] ply.rb - simple .ply file importer

Postby thomthom » Mon Jan 04, 2010 2:50 pm

hm...

Code: Select all
while true
  jim.clone
end


:D
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [plugin] ply.rb - simple .ply file importer

Postby Jim » Mon Jan 04, 2010 2:58 pm

Here's a reasonably-size example:

http://www.cs.virginia.edu/~gfx/Courses ... ls/cow.ply

cow.jpg


Moo.
0
Hi

Jim 
Global Moderator
 

Re: [plugin] ply.rb - simple .ply file importer

Postby notareal » Mon Jan 04, 2010 5:36 pm

Nice. Expecting to see some Chinese gardens with high poly dragons?
0
Welcome to try Thea Render, Thea support | kerkythea.net -team member

notareal 
Thea Render Support
Thea Render Support
 

Re: [plugin] ply.rb - simple .ply file importer

Postby driven » Mon Jan 04, 2010 11:03 pm

MacCow1.jpg


MacCow2.jpg


MacCow3.jpg


Hi,
this could be very handy, but the skinning is not working on mac? is it possible to tweak the code?

john
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [plugin] ply.rb - simple .ply file importer

Postby Jim » Mon Jan 04, 2010 11:14 pm

I don't understand SketchUp sometimes - my cow looked fine and was skinned on import. I did not need to do any cleanup.
0
Hi

Jim 
Global Moderator
 

Re: [plugin] ply.rb - simple .ply file importer

Postby driven » Mon Jan 04, 2010 11:16 pm

how do I revert to standard import to see if it bring faces?

john
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [plugin] ply.rb - simple .ply file importer

Postby thomthom » Mon Jan 04, 2010 11:25 pm

maybe the data is read somewhat differently on Mac..?
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [plugin] ply.rb - simple .ply file importer

Postby Jim » Mon Jan 04, 2010 11:33 pm

Line endings? Seems doubtful, but maybe.. will check.
0
Hi

Jim 
Global Moderator
 

Re: [plugin] ply.rb - simple .ply file importer

Postby thomthom » Mon Jan 04, 2010 11:48 pm

that - or interpretation of commas/periods depending on locale settings...
stabbing in the dark here
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [plugin] ply.rb - simple .ply file importer

Postby Jim » Tue Jan 05, 2010 12:04 am

After reading the spec again, I'm surprised my "naive" implementation from 2006 works at all. I probably had the same thought then as I am having right now - it's hardly worth the effort for such an obscure file format. Good programming exercise, though.
0
Hi

Jim 
Global Moderator
 

Re: [plugin] ply.rb - simple .ply file importer

Postby driven » Tue Jan 05, 2010 12:46 am

Hi again,

I certainly don't NEED it enough to warrant any effort, importing via MeshLab as either odj, dae or dxf is very painless on a mac, for the odd occasion that I'd want to.

the cow, which I copy pasted into a text file, re-named cow.ply is the only .ply I've had any success importing to SU and it won't open in MeshLad (I get a missing header message)

I'm more in need of 'skink-wrapping' of complex engineering geometry which I can't seem to find for Mac SU usage.

john
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [Plugin] .ply file importer (2010/03)

Postby Jim » Mon Mar 22, 2010 6:52 pm

I re-wrote this so it should work with most ascii .ply files that have vertex and face elements. See first post for download.
0
Hi

Jim 
Global Moderator
 

Re: [Plugin] .ply file importer (2010/03)

Postby driven » Mon Mar 22, 2010 7:14 pm

Hi Jim, thanks

I'll try it out later on and see if there's still a Mac issue, cheers

BTW have you ever had a play with Apanta Studio, the PC editor [that's now ported to Mac?]

john
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

so fast you better duck

Postby driven » Mon Mar 22, 2010 7:53 pm

took longer to upload the Jpeg then to load into SU so that's very good, but I now have a request because I may have a use... can it import into a component, to save SU re-calculating all the faces?
bbetter duck.jpg
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [Plugin] .ply file importer (2010/03)

Postby Jim » Mon Mar 22, 2010 8:06 pm

If there is any geometry in the model (i.e. the model is not empty,) then the import is made in a Group. Will that work?

Glad to see it working.
0
Hi

Jim 
Global Moderator
 

Re: [Plugin] .ply file importer (2010/03)

Postby driven » Mon Mar 22, 2010 8:48 pm

yep, there some very good .ply figures out there for just dropping in for a render and casting off... and group scale and move well enough.

cheers
jhon
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [Plugin] .ply file importer (2010/03)

Postby thomthom » Mon Aug 22, 2011 10:19 am

I've been looking around at the various ruby based importers for SketchUp and I see that no one uses the Importer class. If this class is used the importer can be found in the native import list which would be very nice.
http://code.google.com/apis/sketchup/do ... orter.html
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [Plugin] .ply file importer (2010/03)

Postby Jim » Mon Aug 22, 2011 8:45 pm

Yeah, I used it on a ascii/binary .stl importer I wrote - works well.
0
Hi

Jim 
Global Moderator
 

Re: [Plugin] .ply file importer (2010/03)

Postby charly2008 » Mon Aug 22, 2011 11:08 pm

Hi Jim,

Thank you very much. It works very well.

Charly
0
He who makes no mistakes, makes nothing
User avatar
charly2008 
 

Re: [Plugin] .ply file importer (2010/03)

Postby Jim » Wed Aug 24, 2011 10:13 pm

charly2008 wrote:Thank you very much. It works very well.


Thanks, I am as surprised as you. :lol:
0
Hi

Jim 
Global Moderator
 

Re: [Plugin] .ply file importer (2010/03)

Postby tomws » Tue Nov 29, 2011 3:55 pm

<Newbie alert>
I'm trying to understand how to use this plugin (ultimately want to use it to import a terrain mesh). I've 'installed' the plugin and, to try it out, I copied the simple cube shown in http://paulbourke.net/dataformats/ply/ into a file called 'simple_cube.ply' as follows:
ply
format ascii 1.0 { ascii/binary, format version number }
comment made by Greg Turk { comments keyword specified, like all lines }
comment this file is a cube
element vertex 8 { define "vertex" element, 8 of them in file }
property float x { vertex contains float "x" coordinate }
property float y { y coordinate is also a vertex property }
property float z { z coordinate, too }
element face 6 { there are 6 "face" elements in the file }
property list uchar int vertex_index { "vertex_indices" is a list of ints }
end_header { delimits the end of the header }
0 0 0 { start of vertex list }
0 0 1
0 1 1
0 1 0
1 0 0
1 0 1
1 1 1
1 1 0
4 0 1 2 3 { start of face list }
4 7 6 5 4
4 0 4 5 1
4 1 5 6 2
4 2 6 7 3
4 3 7 4 0

I then open SketchupPro V8 and select this plugin from the plugin menu. I select the 'simple_cube.ply' file and get the following result on the Ruby Console:
Error: #<NoMethodError: undefined method `times' for nil:NilClass>
C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/jf_ply_importer.rb:104:in `parse_faces'
C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/jf_ply_importer.rb:102:in `each'
C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/jf_ply_importer.rb:102:in `parse_faces'
C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/jf_ply_importer.rb:51:in `parse'
C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/jf_ply_importer.rb:208:in `ply_import'
C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/jf_ply_importer.rb:231
C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/jf_ply_importer.rb:104:in `call'
C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/jf_ply_importer.rb:104

Uh, what am I doing wrong?

And, if I get past this, what units should I set my vertices to (currently in feet, inches, fractional inches)?

Thanks in advance,
Tom
0

tomws 
 

Re: [Plugin] .ply file importer (2010/03)

Postby Jim » Tue Nov 29, 2011 10:11 pm

Hi Tom,

From the paragraph just before the example you copied... "The comments in brackets are NOT part of the file, they are annotations to this example."

Remove them and the file will import.
0
Hi

Jim 
Global Moderator
 

Re: [Plugin] .ply file importer (2010/03)

Postby tomws » Wed Nov 30, 2011 1:43 am

:oops: Ooops. I feel like such a dweeb...

Thanks for being kind.

May I infer from the resulting cube, that 'units' are in inches and I need to convert all my dimensions to float inches?

Tom

Update: Worked like a champ! Thanks for your help!
0

tomws 
 

Re: [Plugin] .ply file importer (2010/03)

Postby Jim » Wed Nov 30, 2011 10:16 am

TomWS wrote:May I infer from the resulting cube, that 'units' are in inches and I need to convert all my dimensions to float inches?


Well, the .ply file format does not specify units at all, but SketchUp defaults to inches internally.

It's possible to add a units selection dialog for the importer, but the easiest thing to do is just scale the imported geometry to get the size you need.
0
Hi

Jim 
Global Moderator
 

Re: [Plugin] .ply file importer (2010/03)

Postby Jim » Sun Mar 09, 2014 12:26 am

Just a note - my .ply plugin has been adopted by SketchUp, and the code is being hosted on Github. It should soon be available in the Extensions Warehouse.
0
Hi

Jim 
Global Moderator
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 

Next


 

Return to Plugins

Who is online

Users browsing this forum: douglas benta and 9 guests

Visit our sponsors: