To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.cadOpen lugnet.cad in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 CAD / 14165
Subject: 
Re: I found an LDRAW importer for Google SketchUp
Newsgroups: 
lugnet.cad
Date: 
Thu, 2 Nov 2006 15:59:30 GMT
Viewed: 
3327 times
  
Hello,

I just wanted to say hi and that I am trying to work on the plugin everyday. Even so, it’s a slow process. I have some basic functionality but there are a lot of problems.

Right now, it’s posible to import primitives, parts, and models. Multi-part documents (.mpd) are not supported, but it shouldn’t be too hard to add.

You can also create a component and export it, but some things need to be done by hand:

Faces with more than 4 vertices need to be divided so no face has more than 4 vertices. Call it triangulation, or quadrilateral-ization. I’m sure part authors are familiar with the process...

Installation
  • Download ldraw.rb
  • Move or copy it to the Plugins directory where SketchUp is installed.
  • Re-start SketchUp. A sub-menu named LDraw should appear in the Plugins menu.
General Settings
  • Set Units to Decimal Inches with 0 precision. You may also turn off Display units format because you will be working in LDraw Units (LDU’s.) One inch == one LDU. Screenshot
  • Turn on Enable transparency in the Display Settings so you can see transparent colors.
  • Turn off Show: Profiles in the same dialog. (Helps you see errors.) Screenshot
  • Open the Component Browser and make sure it is in List view, then...
  • Close all SketchUp dialogs (Component Browser, Outliner, Layers Dialog) before importing! SketchUp tries to update the dialogs during the import, which makes importing very slow unless they are closed. I’m not sure if I can automate this yet.
  • Set View to Iso
Importing Primitives and Parts
  • Select LDraw -> import menu
  • Select a .dat file to import. I will use (3001.dat)
  • Open the Components window.
For some reason, SketchUp doesn’t update the Component window if it is in Icon view. You may now switch it to Icon view if you like.
  • Find the name of the part/primitive you just imported in the Component browser, select it, and place it at the origin.
(screenshot)

You will notice the part is sitting on the wrong axis. It appears LDraw and SketchUp disagree on which way is up. Don’t worry about it for now.

Notice also you will see all the primitives used by 3001.dat in the Component browser.

If you open the Outliner, you should see how the imported part is really organized. It is a hierachy of primitives, in this case. (Outliner)

As a side note, there is at least one part that gives me problems: 6120.dat . Importing 6120.dat (minifig ski) gives me ski. I can fix this by switching the order of the vertices in the .dat file, but I don’t know how to automatically detect which order to use in the plugin.

Anyway, back to our regulary scheduled program...


Exporting a Model File from Parts
  • Let’s import a few more parts: (3002, 3003, 3004)

  • Notice the Components list doesn’t get that much longer. Components already in the browser don’t get re-loaded.

  • Create a simple model and paint the parts (use colors you know are available by name in LDraw: red, green, blue...)

  • Select all the bricks and create a new component named model1 (Edit -> Make component) You should see it in the Component Browser.

  • Select the new component, and then LDraw -> Export component to .dat from the menu. What is really happening is that each component in the model is being exported as a file reference (line type 1 in LDraw.) The container component provides the filename.

  • Load the file LDraw to test.


Here’s the .dat file produced:

1 2 60 28.0 20.0 1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 3003.dat
1 1 70 4.0 20.0 0.0 0.0 -1.0 0.0 1.0 0.0 1.0 0.0 0.0 3004.dat
1 4 40.0 76.0 20.0 1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 3001.dat
1 14 50 52.0 20 1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 3002.dat
0

Well, that’s it in a nutshell. You can try to make your own components also, but I can’t guarantee it will work:
  1. Draw some faces.
  2. Inport some primitives (if you want.)
  3. Place the primitives.
  4. Make everything into one component.
  5. Select and export it.
  6. Good luck!

Now I need to work on the bathroom remodel before my wife files for divorce...


Subject: 
Re: I found an LDRAW importer for Google SketchUp
Newsgroups: 
lugnet.cad
Date: 
Thu, 2 Nov 2006 20:31:33 GMT
Viewed: 
3004 times
  
In lugnet.cad, Jim Foltz wrote:
   As a side note, there is at least one part that gives me problems: 6120.dat . Importing 6120.dat (minifig ski) gives me ski. I can fix this by switching the order of the vertices in the .dat file, but I don’t know how to automatically detect which order to use in the plugin.

If you look at LDLoader/LDLQuadLine.cpp in the LDView source code, you will find my code for fixing the winding of bow-tie quads. (Specifically, look at LDLQuadLine::swapPointsIfNeeded.) If the algorithm I use isn’t apparent, or you’re not familiar with C++, let me know and I’ll describe it for you.

I don’t know if sketchup has a concept of front and back faces for polygons (I’m guessing it does), but if it does, you won’t be able to determine the proper front surface of polygons for any parts that aren’t BFC-certified. You can, however, automatically generate two polygons containing the same points with opposite windings for any polgons where you don’t know the winding.

--Travis


Subject: 
Re: I found an LDRAW importer for Google SketchUp
Newsgroups: 
lugnet.cad
Date: 
Thu, 2 Nov 2006 22:38:36 GMT
Viewed: 
3002 times
  
In lugnet.cad, Travis Cobbs wrote:
  

If you look at LDLoader/LDLQuadLine.cpp in the LDView source code, you will find my code for fixing the winding of bow-tie quads. (Specifically, look at LDLQuadLine::swapPointsIfNeeded.) If the algorithm I use isn’t apparent, or you’re not familiar with C++, let me know and I’ll describe it for you.

I can’t find it anywhere. I downloaded the source from: http://ldview.sourceforge.net/LDView-2101s.zip. Is this the right zip file?


Subject: 
Re: I found an LDRAW importer for Google SketchUp
Newsgroups: 
lugnet.cad
Date: 
Thu, 2 Nov 2006 23:34:21 GMT
Viewed: 
3124 times
  
In lugnet.cad, Jim Foltz wrote:
   In lugnet.cad, Travis Cobbs wrote:
  

If you look at LDLoader/LDLQuadLine.cpp in the LDView source code, you will find my code for fixing the winding of bow-tie quads. (Specifically, look at LDLQuadLine::swapPointsIfNeeded.) If the algorithm I use isn’t apparent, or you’re not familiar with C++, let me know and I’ll describe it for you.

I can’t find it anywhere. I downloaded the source from: http://ldview.sourceforge.net/LDView-2101s.zip. Is this the right zip file?

No, that’s not the right version, and doesn’t have the file. You can get the latest release’s source from here:

http://prdownloads.sourceforge.net/ldview/LDView-3100s.zip?download

I’ll update my downloads page to include direct links to the more current source. It’s obviously confusing at the momemt.

--Travis


Subject: 
Re: I found an LDRAW importer for Google SketchUp
Newsgroups: 
lugnet.cad
Date: 
Fri, 3 Nov 2006 04:56:04 GMT
Viewed: 
3175 times
  
Just FYI, I updated the LDView downloads page, and it’s now much more clear how to get the current LDView source code. The source code section of that page is here:

http://ldview.sourceforge.net/Downloads.html#SourceCode

--Travis


Subject: 
Re: I found an LDRAW importer for Google SketchUp
Newsgroups: 
lugnet.cad
Date: 
Fri, 3 Nov 2006 16:54:45 GMT
Viewed: 
3153 times
  
In lugnet.cad, Travis Cobbs wrote:
   Just FYI, I updated the LDView downloads page, and it’s now much more clear how to get the current LDView source code. The source code section of that page is here:

http://ldview.sourceforge.net/Downloads.html#SourceCode

--Travis

Thanks Travis, I will have a look.

In the mean time, I have been using the blog to announce the importer/exporter updates. Sketchy Endeavors.


Subject: 
Re: I found an LDRAW importer for Google SketchUp
Newsgroups: 
lugnet.cad
Date: 
Fri, 3 Nov 2006 17:29:22 GMT
Viewed: 
3523 times
  
In lugnet.cad, Jim Foltz wrote:
  
  • Create a simple model and paint the parts (use colors you know are available by name in LDraw: red, green, blue...)

A note on colors. Some LDraw tools (including MLCAD, LDView, L3P) support arbitrary 24-bit color specifications. Use the following in place of the color code for colors you don’t recognize:

0x02RRGGBB

The RRGGBB part is the hex version of the RGB. Make sure to 0-pad. So 255,128,0 would be 0x02FF8000.

You can use the following to get transparent colors:

0x03RRGGBB

Of course, you can’t control the amount of transparency, just whether it’s on or off.

--Travis


Subject: 
Re: I found an LDRAW importer for Google SketchUp
Newsgroups: 
lugnet.cad
Date: 
Sat, 4 Nov 2006 06:09:44 GMT
Viewed: 
3212 times
  
In lugnet.cad, Travis Cobbs wrote:
   Just FYI, I updated the LDView downloads page, and it’s now much more clear how to get the current LDView source code. The source code section of that page is here:

http://ldview.sourceforge.net/Downloads.html#SourceCode

--Travis

Tanks Travis, I got it working. Your code was neat and clear; you must do it professionally.

Here’s a before and after:






Subject: 
Re: I found an LDRAW importer for Google SketchUp
Newsgroups: 
lugnet.cad
Date: 
Sat, 4 Nov 2006 18:24:45 GMT
Viewed: 
3427 times
  
In lugnet.cad, Travis Cobbs wrote:

A note on colors.  Some LDraw tools (including MLCAD, LDView, L3P) support
arbitrary 24-bit color specifications.  Use the following in place of the
color code for colors you don't recognize:

Thanks for the tip.

I plan on having a custom pallet in SketchUp with all the ldraw colors
available. Of course, you can create your own colors too. A custom color will
get exported as you describe below.


0x02RRGGBB

The RRGGBB part is the hex version of the RGB.  Make sure to 0-pad.  So
255,128,0 would be 0x02FF8000.

You can use the following to get transparent colors:

0x03RRGGBB

Of course, you can't control the amount of transparency, just whether it's on
or off.

I'd use 50% in that case.


--Travis


©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR