SOLIDWORKS API Help
SOLIDWORKS Connected
As of SOLIDWORKS 2020 SP03.1, SOLIDWORKS can run on the 3DEXPERIENCE
platform as SOLIDWORKS Connected. SOLIDWORKS Connected provides access to all
the 3DEXPERIENCE services and apps that you are entitled to use
based on your role. Before using the SOLIDWORKS APIs with SOLIDWORKS Connected,
you must install and set up roles and collaborative spaces in the 3DEXPERIENCE
platform and install SOLIDWORKS Connected.
Read SOLIDWORKS Connected Help > Installation.
Using SOLIDWORKS APIs with SOLIDWORKS
Connected
As with SOLIDWORKS Desktop, you can use the
Macro toolbar in SOLIDWORKS Connected to create and edit macros. Macros are
saved in the local directories that you specify. You can make references to type
libraries and interop assemblies in the local SOLIDWORKS installation that
SOLIDWORKS Connected deploys. You can also presume that most of your working
SOLIDWORKS macros will also work with SOLIDWORKS Connected. However due
3DEXPERIENCE file storage, some SOLIDWORKS APIs have been added,
changed, or discontinued for use with SOLIDWORKS Connected.
Note the following:
-
SOLIDWORKS Connected opens 3DEXPERIENCE
documents with limited options. See the
ISldWorks::OpenDoc7 and
IDocumentSpecification Remarks.
-
Open a part in one of two modes:
Resolved or Quick View.
-
Open an assembly in one of three modes:
Large Design Review, LightWeight, or Resolved. You can also opt to use
Speedpak and load hidden components.
-
Open a drawing in one of four modes:
Quick View, Detailing, LightWeight, or Resolved. You can also opt to use
Speedpak.
-
See IDocumentSpecification::Selective,
IDocumentSpecification::LightWeight,
IDocumentSpecification::UseLightWeightDefault,
IDocumentSpecification::ViewOnly, IDocumentSpecification::DetailingMode,
IDocumentSpecification::UseSpeedPak, and
IDocumentSpecification::IgnoreHiddenComponents.
-
Documents opened with SOLIDWORKS Connected
can be saved only to a 3DEXPERIENCE collaborative space
that you previously set up. Documents cannot be saved locally and, once
saved to the 3DEXPERIENCE platform with SOLIDWORKS
Connected, cannot be retrieved from outside of the 3DEXPERIENCE
platform.
-
Documents that have been saved with either
SOLIDWORKS Desktop or SOLIDWORKS Connected can be opened with SOLIDWORKS
Connected. However, documents saved with SOLIDWORKS Connected can only be
opened from within the 3DEXPERIENCE platform or with
SOLIDWORKS Connected.
-
SOLIDWORKS Connected employs the Product
Lifecycle Management (PLM) software provided by 3DEXPERIENCE.
Therefore, the SOLIDWORKS PDM Pro API does not work with SOLDWORKS
Connected.
APIs that support opening and saving documents
with SOLIDWORKS Connected are available as of SOLIDWORKS 2020 SP03.1. In future
releases, more APIs specific to SOLIDWORKS Connected functionality may be added.
You should always read the API Help Release Notes in each service pack to learn
about API changes for SOLIDWORKS Connected functionality. Use the Index and
Search tabs in the SOLIDWORKS API Help to search for "3DEXPERIENCE" or
"SOLIDWORKS Connected".
After you install SOLIDWORKS Connected, run the
following two examples in order:
Example 1: Save a SOLIDWORKS Connected
document
' VBA
' Preconditions: Open a new part with SOLIDWORKS Connected.
' Postconditions:
' 1. NonActiveSave.sldprt is saved to a collaborative space
on the 3DEXPERIENCE platform.
' 2. Use 3DEXPERIENCE 3DSearch to find
NonActiveSave.sldprt on the 3DEXPERIENCE
platform.
' 3. Do not close the document as Example 2 requires that it be open.
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As
SldWorks.ModelDoc2
Dim swModExt As SldWorks.ModelDocExtension
Dim
swSaveTo3DExp As SldWorks.SaveTo3DExperienceOptions
Dim strFileName,
strComment As String
Dim bStat As Boolean
Dim lError As Long
Dim
IWarning As Long
Sub main()
Set swApp =
Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swModExt = swModel.Extension
If swApp.ApplicationType =
swApplicationType_3DEXPERIENCE Then
Set swSaveTo3DExp
= swApp.GetSaveTo3DExperienceOptions
strFileName = "NonActiveSave.sldprt"
strComment = "No comment"
swSaveTo3DExp.FileName = strFileName
bStat = swSaveTo3DExp.SetRevisionComments(strComment)
bStat = swModExt.SaveTo3DExperience(swSaveTo3DExp, lError,
IWarning)
End If
End Sub
Example 2: Open a SOLIDWORKS Connected document
' VBA
' Preconditions:
' 1. NonActiveSave.sldprt is open in
SOLIDWORKS Connected.
' 2. Open the Immediate window.
' 3. Run the macro.
' 4. When the macro stops, close the document.
' 5. Press F5 to reopen the
3DEXPERIENCE document.
' Postconditions: NonActiveSave.sldprt is re-opened from the
3DEXPERIENCE platform.
Option Explicit
Dim swApp As
SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swModExt As
SldWorks.ModelDocExtension
Dim swPart As SldWorks.PartDoc
Dim
swPLMObjectSpecification As SldWorks.PLMObjectSpecification
Dim
swDocSpecification As SldWorks.DocumentSpecification
Dim strPartTitle As
String
Dim strPLMid As String
Sub main()
Set swApp = Application.SldWorks
Set swModel =
swApp.ActiveDoc
Set swModExt =
swModel.Extension
If swApp.ApplicationType
= swApplicationType_3DEXPERIENCE Then
strPLMid = swModExt.GetPLMID
Debug.Print swModel.GetPathName & " " & strPLMid
Stop 'Close document in the user interface
'Open 3DEXPERIENCE document using the API
Set swDocSpecification = swApp.GetOpenDocSpec("")
Set swPLMObjectSpecification = swDocSpecification.PLMObjectSpecification
swPLMObjectSpecification.PLMID = strPLMid
Set swModel = swApp.OpenDoc7(swDocSpecification)
End If
End Sub
Also see the
IPLMObjectSpecification .NET examples.