Reply

SaveAsImage VRML

[ Edited ]

 

Hi everybody, i'm new here, nice place! 

Could someone tell me how i can save as VRML (.wrl) an assembly document or a part document?

I've find the SaveAsImage command in the guide but i don't understand the way it works 'cause there's no examples about it.

It seems similar to SaveAs method but i don't understand why it doesn't work..

thanks 4 any kind of suggestion

 

Posted by: fabrizio franceschi
Post date: 2/14/2008 6:40:35 AM

6 REPLIES

RE: SaveAsImage VRML

[ Edited ]

Should be as easy as calling:

 

objDocument.SaveAsImage("Part1.wrl")

 

All of the other arguments are optional.

 

Posted by: Jason Newell
Post date: 2/15/2008 6:28:05 AM

RE: SaveAsImage VRML

[ Edited ]

 

Thanks Jason, i've tried to do what you say but SE open the file and it saves nothing.

 

I think there's something setting not properly in SE or in VBA..

why "SaveAsImage" does not appears in the list below while i write the code? I use VBA in Excel and this code run properly with "SaveAs" method but not with "SaveAsImage". Could someone try to copy & paste this code and tell me if it works on another pc? so i can understand if the problem is resident on my pc or not

 

 

 

Sub saveasimage()

Dim objApp As SolidEdgeFramework.Application

Dim objDoc As SolidEdgePart.PartDocument

Dim objSummaryInfo As SolidEdgeFramework.SummaryInfo

Dim varSaveDate As String

Dim sysTime As String

Const TESTFILE = "C:\test\comp1.par"

Const SAVEFILE = "C:\test\success.wrl"

' Report errors

Const PI = 3.14159265358979

' Create/get the application with specific settings

On Error Resume Next

Set objApp = GetObject(, "SolidEdge.Application")

    If Err Then

        Err.Clear

        Set objApp = CreateObject("SolidEdge.Application")

        Set objDoc = objApp.Documents.Add("SolidEdge.PartDocument")

        objApp.Visible = True

    Else

        Set objDoc = objApp.ActiveDocument

    End If

Call objDoc.Close

' opening the file

Set objDoc = objApp.Documents.Open(TESTFILE)

' saving the file as another file

Call objDoc.SaveAsImage(SAVEFILE)

' USER DISPLAY

' Release objects

Set objApp = Nothing

Set objDoc = Nothing

Set objSummaryInfo = Nothing

End Sub

 

Posted by: fabrizio franceschi
Post date: 2/16/2008 1:55:03 AM

RE: SaveAsImage VRML

[ Edited ]

 

Hello Uncle,

the SaveAsImage method apply to the SolidEdgeDraft.SheetWindow and to SolidEdgeFramework.View object. The SaveAs method is only for other cad formats like step stp etc, but not for images like tif or jpg.

regards,

Sibi

 

Posted by: Seb Sosna
Post date: 2/16/2008 6:52:49 AM

RE: SaveAsImage VRML

[ Edited ]

 

Thanks Sibi, your suggestion is right! 

SaveAsImage must be applied to active view. Now with the code below i can generate a valid VRML (.wrl) file.

But.. something strange happens : in the VRML file there's only views and lights definitions. Any definitions about 3D model are missed so the result is a VRML file with an empty scene of 3kb size.

Could someone tell me if there's something wrong or some parameter miss or other to set?

 

 

 

Sub saveasimage()

Dim objApp As SolidEdgeFramework.Application

Dim objDoc As SolidEdgePart.PartDocument

Dim actWnd As SolidEdgeFramework.Window

Dim activeView As SolidEdgeFramework.View

Dim objSummaryInfo As SolidEdgeFramework.SummaryInfo

Dim varSaveDate As String

Dim sysTime As String

Const TESTFILE = "C:\test\comp1.par"

Const SAVEFILE = "C:\test\success.wrl"

' Report errors

Const PI = 3.14159265358979

' Create/get the application with specific settings

On Error Resume Next

Set objApp = GetObject(, "SolidEdge.Application")

    If Err Then

        Err.Clear

        Set objApp = CreateObject("SolidEdge.Application")

        Set objDoc = objApp.Documents.Add("SolidEdge.PartDocument")

        objApp.Visible = True

    Else

        Set objDoc = objApp.ActiveDocument

    End If

Call objDoc.Close

' opening the file

Set objDoc = objApp.Documents.Open(TESTFILE)

' saving the file as another file

Set actWnd = objApp.ActiveWindow

Set activeView = actWnd.View

'activeView.SetRenderMode (seRenderModeSmooth)

Call activeView.saveasimage(SAVEFILE)

' Release objects

Set objApp = Nothing

Set objDoc = Nothing

Set objSummaryInfo = Nothing

End Sub

 

Posted by: fabrizio franceschi
Post date: 2/17/2008 1:18:46 AM

RE: SaveAsImage VRML

[ Edited ]

 

Hi Uncle,

use SolidEdgeDraft.SheetWindow instead of View. Get from the DraftDocument the Window.Item(x) sheet and assignit to a SheetWindow  object variable. Then call SaveImageAs. Note if your arguments are too big (size,resolution,quality) you will get an out of memory exception. Here is an example which works for me:

sheet.SaveAsImage("e:\\SaveAs_.tif",

                                                sheet.Width / 30,

                                                sheet.Height / 30,

                                                30, //Resolution = ???

                                                24, //Color Depth

                                                SeImageQualityType.seImageQualityHigh,

                                                false);

regards,

Sibi

 

 

 

Posted by: Seb Sosna
Post date: 2/17/2008 1:51:19 AM

RE: SaveAsImage VRML

[ Edited ]

 

The VRML format is a 3D model and i must obtain it obligatorily from a part or an assembly.

Imho the option ".wrl" would have to be put in the "Save as" menù or method, i don't know why SE programmers put it into "Save as Image" menu & method..

but..

few minute ago I've tried to restart my pc and when i've start the macro again a wonderful things was happened: it works correctly with the code posts before!

maybe my pc needs to restart sometimes and/or some kind of process control will be necessary, but now an important step has been made, so..

A lot of thanks again Sibi!

uncle

 

Posted by: fabrizio franceschi
Post date: 2/17/2008 2:47:57 AM