Hide Table of Contents
OpenDoc6 Method (ISldWorks)

Opens an existing document and returns a pointer to the document object.

.NET Syntax

Visual Basic (Declaration) 
Function OpenDoc6( _
   ByVal FileName As String, _
   ByVal Type As Integer, _
   ByVal Options As Integer, _
   ByVal Configuration As String, _
   ByRef Errors As Integer, _
   ByRef Warnings As Integer _
) As ModelDoc2
Visual Basic (Usage) 
Dim instance As ISldWorks
Dim FileName As String
Dim Type As Integer
Dim Options As Integer
Dim Configuration As String
Dim Errors As Integer
Dim Warnings As Integer
Dim value As ModelDoc2
 
value = instance.OpenDoc6(FileName, Type, Options, Configuration, Errors, Warnings)
C# 
ModelDoc2 OpenDoc6( 
   string FileName,
   int Type,
   int Options,
   string Configuration,
   out int Errors,
   out int Warnings
)
C++/CLI 
ModelDoc2^ OpenDoc6( 
&   String^ FileName,
&   int Type,
&   int Options,
&   String^ Configuration,
&   [Out] int Errors,
&   [Out] int Warnings
) 

Parameters

FileName

Document name or full path if not in current directory, including extension

Type

Document type as defined in swDocumentTypes_e

Options

Mode in which to open the document as defined in swOpenDocOptions_e

Configuration

Model configuration in which to open this document

  • Applies to parts and assemblies, not drawings

  • If this argument is empty or the specified configuration is not present in the model, the model is opened in the last-used configuration

Errors

Load errors as defined in swFileLoadError_e

Warnings

Warnings or extra information generated during the open operation as defined in swFileLoadWarning_e

Return Value

Newly loaded model document or NULL if document failed to open

Example

Remarks

This method also allows control over whether to:
  • Suppress displaying dialog boxes

  • Open the document read-only

  • Open the document view-only

  • Convert a drawing to a detached drawing

When opening a parent document (assembly, drawing, and so on):

  • SolidWorks also opens any additional documents that are referenced in the parent document (parts, subassemblies, and so on).

  • SolidWorks follows certain rules in trying to locate its referenced documents. If explicit Search Folders have not been set using Tools, Options, System Options, ExternalReferences, then the first place SolidWorks looks for the referenced documents is in the current working directory. If SolidWorks finds the referenced file in the current working directory, then it is loaded from that directory.

Calling ISldWorks::OpenDoc6 does not change the current working directory to that of the opened file, whereas, interactively using the File Open dialog box does. This may affect documents with references.

Because the user may have interactively opened files from some random directory, you cannot be certain that the current working directory is pointing to the desired location. This may affect the referenced documents that ultimately get loaded when using ISldWorks::OpenDoc6 versus performing File Open interactively. You may want to set the current working directory before calling ISldWorks::OpenDoc6. This can be done using the ISldWorks::SetCurrentWorkingDirectory method. To mimic the behavior of the File Open dialog, you set the current working directory to that of the file being opened.

When opening files that contain references, you may also want to consider the current Search Folder settings because they may affect the references that ultimately get loaded. This can be done using ISldWorks::GetSearchFolders and ISldWorks::SetSearchFolders. If Search Folders are currently in use, SolidWorks looks for references in the Search Folders before trying to locate references in the current working directory.

ISldWorks::OpenDoc6 does not activate and display the document if the file is already open in memory in an assembly or drawing. However, ISldWorks::OpenDoc6 should return a valid IModelDoc2 pointer that is usable with functions that do not require a document to be displayed. If you want, ISldWorks::ActivateDoc2 or ISldWorks::IActivateDoc3 will activate and display the document. Because calling ISldWorks::OpenDoc6 does not activate nor display the file, calling the ISldWorks::ActiveDoc or ISldWorks::IActiveDoc2 property will not return a pointer to this document.

This method fires the the SolidWorks event FileOpenNotify2 event. Also, the SolidWorks event ActiveDocChangeNotify and ActiveModelDocChangeNotify events are sent if the file being loaded is not already open as the active document.

 

TIPS

To...

Then...

Avoid a warning when opening the document

Set the Options argument to swOpenDocOptions_AutoMissingConfig and swOpenDocOptions_Silent with the Boolean OR operator. The effect of using last-displayed configuration is the same.

Open a library feature part

Use swDocPART for the Type argument.

Open foreign files (IGES, STEP, and so on)

Use ISldWorks::LoadFile4.

Avoid a warning when opening shaded models in views

Set the Options argument to swOpenDocOptions_LoadModel. This option loads the model so that the view comes in shaded automatically.

Avoid large increases in memory usage caused when adding parts to assemblies

 

Opening a model causes SceneGraph to display the model. SceneGraph uses maps with defaults sizes of 2MB - 3MB for even the simplest model. And, assemblies and parts do not share the same SceneGraph buffer. To avoid large increases in your memory usage:

  1. Set the document to invisible.

  2. Open the parts.

  3. Set the document to visible.

  4. Add the part to the assembly.

See ISldWorks::DocumentVisible for details.

Open a document with a specifed display state Use ISldWorks::OpenDoc7.

A warning is displayed if you open a RapidDraft drawing without loading the model, and the model was saved since the drawing was last saved.

This method honors the ISldWorks::GetUserPreferenceIntegerValue and ISldWorks::SetUserPreferenceIntegerValue swLargeAsmModeAutoActivate, swPromptAlwaysNever_e setting.

 

See Also

Availability

SolidWorks 2001Plus FCS, Revision Number 10.0


Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

 
*Email:  
Subject:   Feedback on Help Topics
Page:   OpenDoc6 Method (ISldWorks)
*Comment:  
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:



x

We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again
x

Web Help Content Version: API Help (English only) 2010 SP05

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.