Export of .mpd to single 'stand-alone' .ldr file ?


Re: Export of .mpd to single 'stand-alone' .ldr file ?
#12
OK hold the front page - I think I have cracked it !!!

Attached is my 'flattened' version of the file I attached in my previous post (only line type 1's included)

(When I looked at this a couple of months back I literally spent a week solid trying to get this to work - amazing what coming back afresh can do - and Travis's step by step method list was also the catalyst which got it working - so thanks Travis).

The code (for those who are interested in these things) is as follows (the Ldrawpart is my own class - not included here).

Function Flatten(ByVal cModelFile As String, ByVal oParentMatrix As Windows.Media.Media3D.Matrix3D)

Dim cModelData As String = IO.File.ReadAllText(cModelFile)
Dim aLines As Array = Split(RemoveTrailingLineFeeds(cModelData), vbCrLf)
Dim oPart As LDrawPart

For Each cLine In aLines
oPart = New LDrawPart(cLine, ExtractPath(cModelFile) & "\")
If oPart.LineType = 1 Then
If LCase(RightStr(oPart.DatFile, 4)) = ".ldr" Then
Flatten(ExtractPath(cModelFile) & "\" & oPart.DatFile, oPart.Matrix3d)
Else
Dim oNewMatrix As Matrix3D = Matrix3D.Multiply(oPart.Matrix3d, oParentMatrix)
cCombinedData = cCombinedData & oPart.LineType & " " & _
oPart.Colour & " " & _
oNewMatrix.OffsetX & " " & _
oNewMatrix.OffsetY & " " & _
oNewMatrix.OffsetZ & " " & _
oNewMatrix.M11 & " " & _
oNewMatrix.M21 & " " & _
oNewMatrix.M31 & " " & _
oNewMatrix.M12 & " " & _
oNewMatrix.M22 & " " & _
oNewMatrix.M32 & " " & _
oNewMatrix.M13 & " " & _
oNewMatrix.M23 & " " & _
oNewMatrix.M33 & " " & _
oPart.DatFile & vbCrLf
End If
Else
cCombinedData = cCombinedData & cLine & vbCrLf
End If
Next

IO.File.WriteAllText(ExtractPath(cModelFile) & "\flattened.ldr", cCombinedData)

End Function


(This function assumes all 'in-line' ldr files in the MPD file have already been extracted as seperate files (in the same folder/directory) as the 'base' file - that's easy to do).

This is SO much simpler that what I was trying before !

HOORAY ITS CHRISTMAS !


Attached Files
.ldr   flattened.ldr (Size: 18.54 KB / Downloads: 1)
Reply
« Next Oldest | Next Newest »



Messages In This Thread
Re: Export of .mpd to single 'stand-alone' .ldr file ? - by Rob - 2012-12-20, 22:45

Forum Jump:


Users browsing this thread: 3 Guest(s)