Hide Table of Contents
OpenDoc7 Method (ISldWorks)

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

.NET Syntax

Visual Basic (Declaration) 
Function OpenDoc7( _
   ByVal Specification As System.Object _
) As ModelDoc2
Visual Basic (Usage) 
Dim instance As ISldWorks
Dim Specification As System.Object
Dim value As ModelDoc2
value = instance.OpenDoc7(Specification)
ModelDoc2 OpenDoc7( 
   System.object Specification
ModelDoc2^ OpenDoc7( 
&   System.Object^ Specification


Document specification

Return Value




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::OpenDoc7 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::OpenDoc7 versus performing File Open interactively. You may want to set the current working directory before calling ISldWorks::OpenDoc7. 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::OpenDoc7 does not activate and display the document if the file is already open in memory in an assembly or drawing. However, ISldWorks::OpenDoc7 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::OpenDoc7 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 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.





Open an assembly in Large Design Review mode

Set IDocumentSpecification::ViewOnly to true. 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 a warning when opening the document

Set IDocumentSpecification::Silent to true.

Open a library feature part

Set IDocumentSpecification::DocumentType to swDocumentTypes_e.swDocPART.

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

Use ISldWorks::LoadFile4.

Avoid a warning when opening shaded models in views

Set IDocumentSpecification::LoadModel to true. 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.

To open a document without a specified display state Use ISldWorks::OpenDoc6.

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


SOLIDWORKS 2008 FCS, Revision Number 16.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

Subject:   Feedback on Help Topics
Page:   OpenDoc7 Method (ISldWorks)
*   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:


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

Web Help Content Version: API Help (English only) 2015 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.