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 System.String, _
   ByVal Type As System.Integer, _
   ByVal Options As System.Integer, _
   ByVal Configuration As System.String, _
   ByRef Errors As System.Integer, _
   ByRef Warnings As System.Integer _
) As ModelDoc2
Visual Basic (Usage) 
Dim instance As ISldWorks
Dim FileName As System.String
Dim Type As System.Integer
Dim Options As System.Integer
Dim Configuration As System.String
Dim Errors As System.Integer
Dim Warnings As System.Integer
Dim value As ModelDoc2
 
value = instance.OpenDoc6(FileName, Type, Options, Configuration, Errors, Warnings)
C# 
ModelDoc2 OpenDoc6( 
   System.string FileName,
   System.int Type,
   System.int Options,
   System.string Configuration,
   out System.int Errors,
   out System.int Warnings
)
C++/CLI 
ModelDoc2^ OpenDoc6( 
&   System.String^ FileName,
&   System.int Type,
&   System.int Options,
&   System.String^ Configuration,
&   [Out] System.int Errors,
&   [Out] System.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 (See Remarks)

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

As of SOLIDWORKS 2012 SP5, loading future file versions is supported, and ISldWorks::OpenDoc6 no longer throws a swFileLoadError_e.swFutureVersion error. Use IModelDocExtension::IsFutureVersion to determine whether a component is for a future version of SOLIDWORKS.

As of SOLIDWORKS 2008, ISldWorks::OpenDoc7 performs the same work as this method, but also:

  • Allows you to open a document with a specified display state.
  • Uses IDocumentSpecification to specify input parameters.

This method also allows control over whether to:

  • Suppress displaying dialog boxes

  • Open the document read-only

  • Open the document in Large Design Review mode

  • 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.

If this method successfully opens an assembly, it still returns swFileLoadError_e.swFileNotFoundError in Errors if a referenced component file cannot be located.

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...

Open an assembly in Large Design Review mode

Set the Options argument to swOpenDocOptions_ViewOnly. This option displays large assemblies without actually loading them. This is useful for conducting a quick walk-through of a large assembly. Call IAssemblyDoc::SelectiveOpen to open selected components after an assembly has been opened in Large Design Review mode.

Avoid warnings when opening the document

Set the Options argument to swOpenDocOptions_Silent. The software uses the last-displayed configuration if it discovers missing configurations or component references.

Open a library feature part

Set the Type argument to swDocPART.

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 specified display state Use ISldWorks::OpenDoc7.

A warning is displayed if you open a Detached 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) 2019 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.