R$0.00
0

What Is New in the SOLIDWORKS 2027 API

The SOLIDWORKS 2027 API adds frozen models, a legacy sheet metal upgrade, named exploded views in drawings and balloon quantity spacing. Here is each new member with VBA macro examples.
Picture of Amen Jlili

Amen Jlili

Amen Jlili is the founder and technical director of Blue Byte Systems Inc., a software company in Vancouver, Canada, specializing in automating SOLIDWORKS and PDM.

The SOLIDWORKS 2027 API adds seven new members in three areas: saving and reopening models in a frozen state, upgrading legacy sheet metal features, and better control of exploded views and balloons in drawings. This post walks through each one with VBA macro examples, and what it means for your macros and add-ins.

Everything here comes from the SOLIDWORKS API 2027 release notes, which are published as a pre-release (PR1) help. Names and behavior can still change before the final release, so test against the shipping version before you deploy.

What is new at a glance

InterfaceMemberWhat it does
IModelDocExtensionIsFrozenTells you if the model is frozen
IModelDocExtensionSaveAndFreezeSaves the model in a frozen state
IModelDocExtensionUnFreezeUnfreezes the model
IModelDocExtensionUpgradeLegacySheetMetalUpgrades legacy sheet metal features to the current architecture
IViewShowExploded2Shows a named exploded view in a drawing view
IViewGetVerticesOfVisibleEntitiesGets vertices of visible entities, exploded or not
IBalloonOptionsQuantityDistanceSets the distance between a balloon and its BOM quantity

1. Save models in a frozen state

The biggest addition is support for frozen models. A frozen model is saved so that it is protected from being rebuilt or changed until it is unfrozen. Three new methods on IModelDocExtension give you full control from code.

  • IsFrozen returns true if the document is frozen.
  • SaveAndFreeze(FreezeOption) saves the model and freezes it. It returns true if the model was frozen.
  • UnFreeze(FreezeOption) unfreezes it again. It returns true if the model was unfrozen.

Both SaveAndFreeze and UnFreeze take a value from the new swFreezeOptions_e enumeration:

ValueMeaning
swFreezeOptions_Default (0)Freeze or unfreeze the part. For assemblies and drawings it behaves like AllComponents.
swFreezeOptions_AllComponents (1)Freeze or unfreeze the top level assembly or drawing and all component models.
swFreezeOptions_TopOnly (2)Freeze or unfreeze only the top level assembly or drawing.
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swExt As SldWorks.ModelDocExtension
Dim frozen As Boolean
Dim unfrozen As Boolean

Sub main()

    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swExt = swModel.Extension

    If Not swExt.IsFrozen Then
        ' Save the assembly and every component in a frozen state
        frozen = swExt.SaveAndFreeze(swFreezeOptions_AllComponents)
    End If

    ' Later, unfreeze only the top level assembly
    unfrozen = swExt.UnFreeze(swFreezeOptions_TopOnly)

End Sub

Where this helps

  • Released designs: freeze an assembly and its components when it reaches Released in your PDM workflow, so nobody rebuilds it by accident.
  • Batch tools: check IsFrozen before your macro rebuilds, saves or edits a file, and skip or unfreeze it on purpose.
  • Customer deliveries: hand over a model that opens exactly as it was saved.

If you run batch rebuild or property update tools, add an IsFrozen check now. A frozen file that your code tries to change is a support call waiting to happen.

2. Upgrade legacy sheet metal from code

UpgradeLegacySheetMetal upgrades legacy sheet metal features to the current architecture. It takes no arguments and returns true if the features were upgraded.

Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim errors As Long
Dim warnings As Long

Sub main()

    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc

    If swModel.Extension.UpgradeLegacySheetMetal Then
        swModel.Save3 swSaveAsOptions_Silent, errors, warnings
    End If

End Sub

Vaults that have collected sheet metal parts over many SOLIDWORKS versions can now be upgraded in a batch instead of part by part. Run it on a copy first, compare the flat patterns, then roll it out.

3. Exploded views in drawings

Two new IView methods improve how drawings work with exploded assemblies.

ShowExploded2

ShowExploded2(ShowExploded, ExplodeViewName) shows a named exploded view in the drawing view. Pass true and the name of the exploded view to show it, or false to show the collapsed state. Unlike the older method, you choose exactly which exploded view appears.

Dim swApp As SldWorks.SldWorks
Dim swDraw As SldWorks.DrawingDoc
Dim swView As SldWorks.View
Dim shown As Boolean

Sub main()

    Set swApp = Application.SldWorks
    Set swDraw = swApp.ActiveDoc
    Set swView = swDraw.ActiveDrawingView

    shown = swView.ShowExploded2(True, "ExplView1")

End Sub

GetVerticesOfVisibleEntities

GetVerticesOfVisibleEntities gets the vertices of the visible entities of a component in a drawing view, regardless of its exploded state. You pass the component and an entity type from swViewEntityType_e, and get back the visible entities and, for each one, an array of MathPoint objects for its vertices.

Dim swComp As SldWorks.Component2   ' a component shown in swView
Dim vEntities As Variant
Dim vCoordinates As Variant

swView.GetVerticesOfVisibleEntities swComp, swViewEntityType_Edge, vEntities, vCoordinates

This is useful for tools that place annotations, dimensions or balloons automatically, because you get positions that match what is actually visible in the view.

4. Balloon quantity distance

IBalloonOptions has a new QuantityDistance property. It gets and sets the distance between the BOM item quantity and its balloon, so automated ballooning can match your drafting standard without manual cleanup. Like all API lengths, the value is in meters.

Dim swOptions As SldWorks.BalloonOptions

Set swOptions = swModel.Extension.CreateBalloonOptions
swOptions.QuantityDistance = 0.003   ' 3 mm

Should you update your code?

  • Batch tools that rebuild, save or edit files: add an IsFrozen check.
  • Workflows that release designs: consider SaveAndFreeze as part of your release automation.
  • Older sheet metal libraries: plan a test of UpgradeLegacySheetMetal on a copy.
  • Drawing automation with exploded views or balloons: switch to ShowExploded2 and try QuantityDistance.

Each member is marked as available from SOLIDWORKS 2027 SP0, revision 35.0. If your add-in also supports older versions, check the SOLIDWORKS revision before calling them.

Need help with the SOLIDWORKS API?

Blue Byte Systems builds SOLIDWORKS and SOLIDWORKS PDM add-ins, tasks and integrations, and Amen Jlili leads the SOLIDWORKS APIs User Group. If you want help updating your tools for 2027, book a short call.

Need this adapted to your workflow?

We build custom SOLIDWORKS macros, add-ins and PDM automation.

Picture of Amen Jlili

Amen Jlili

Amen Jlili is the founder and technical director of Blue Byte Systems Inc., a software company in Vancouver, Canada, specializing in automating SOLIDWORKS and PDM.

Leave a Comment

0
0
Your Cart
Your cart is emptyReturn to Shop