Welcome
Collapse Getting StartedGetting Started
Overview
Expand Types of SolidWorks API ApplicationsTypes of SolidWorks API Applications
Expand SolidWorks API Object Model and Class HierarchySolidWorks API Object Model and Class Hierarchy
Collapse Programming with the SolidWorks APIProgramming with the SolidWorks API
Expand Add-insAdd-ins
API Dependent on SolidWorks Being Visible
Arrays
Attributes Imported from ACIS SAT Files
Bitmasks
Block Definitions and Block Instances
Bodies in Body Folders
BOOL and VARIANT_BOOL
Bounding Box and Note Text
COM vs. Dispatch
CommandManager and CommandGroups
Components, Configurations, and Suppression States
Compound Note
ComVisibleAttribute in VSTA macros
Controls, Visual Basic 6.0, and Windows XP
Expand Double Arrays and Integer PairsDouble Arrays and Integer Pairs
Drawing Views and Model Entities
Early and Late Binding
Expand EventsEvents
Features of Components
Helper Functions
Hole Wizard Features and Objects
IDispatch Object Arrays as Input in .NET
Implementation Guidelines
Import and Export File Options
In-process Methods
Instantiate ActiveX Controls as Tabs
Interface Pointers
Keystrokes and Accelerator Keys
Library Features and Objects
Lightweight Components
Line Attributes for View::GetPolyLinesAndCurves
Line Weights
Long vs. Integer
Expand Macro FeaturesMacro Features
Manipulators
Mass Properties
Collapse Multibody PartsMultibody Parts
Option Explicit Statement
Partition Rollback and API Handles
Persistent Reference IDs
Presentation Transforms
Expand PropertyManager PagesPropertyManager Pages
.NET Interop Assemblies
Quick Tips and Bubble ToolTips
Return Values
Expand SafeArraysSafeArrays
Selection Criteria
Selection Lists
Selections that Define Features
Setup Project to Distribute SolidWorks Add-in
Smart Pointers
SolidWorks Objects
Sorting Tables
SQLite
STL Container Classes and Smart Pointers
Suspend Automatic Rebuilds
System Options and Document Properties
Tessellation and Edges
Tracking IDs
Expand Type LibrariesType Libraries
Units
Unmanaged C++ and C++/CLI Code
VBA and SolidWorks x64
Examples and Projects
Expand SolidWorks API HelpSolidWorks API Help
Expand FeatureWorks API HelpFeatureWorks API Help
Expand SolidWorks Costing API HelpSolidWorks Costing API Help
Expand SolidWorks Document Manager API HelpSolidWorks Document Manager API Help
Expand SolidWorks Routing API HelpSolidWorks Routing API Help
Expand SolidWorks Simulation API HelpSolidWorks Simulation API Help
Expand SolidWorks Sustainability API HelpSolidWorks Sustainability API Help
Expand SolidWorks Toolbox API HelpSolidWorks Toolbox API Help
Expand SolidWorks Utilities API HelpSolidWorks Utilities API Help
Expand SolidWorks Workgroup PDM API HelpSolidWorks Workgroup PDM API Help
Expand eDrawings API HelpeDrawings API Help
Hide Table of Contents

Programming Multibody Parts

This topic provides information about programming multibody parts using the SolidWorks API. Click a link to read that section.

Obsoleted methods and their replacements

When programming multibody parts:

Do not use...

Instead, use...

Because...

IFeature::GetBody

IFeature::GetFaces

IFace2::GetBody

A feature can affect more than one body. Therefore, getting the faces created by a feature and getting the bodies to which the faces belong is a better way to get a feature's body or bodies.

IPartDoc::Body

IPartDoc::IBodyObject2

 

It no longer makes sense to get the body of a part if it contains multiple bodies. In a single-body part, IPartDoc::Body and IPartDoc::IBodyObject2 still return the body, but in a multibody part, they return NULL.

Back to top

Changes to base features

Most of the methods for creating base features (cut and boss, including thin features) belong to IFeatureManager:

  • Extrude

  • Revolve

  • Sweep

  • Loft

  • Thicken

 

These methods may include any of the following parameters that support multibody parts:

If this parameter...

Is set to...

Then...

merge

TRUE

Merging occurs and feature scope applies.

 

FALSE

Merging does not occur and feature scope does not apply.

useFeatScope

TRUE

All currently selected bodies are affected.

 

FALSE

All applicable bodies are affected .

UseAutoSelect

TRUE

All applicable bodies are added to the selection list, which the user can edit.

 

FALSE

User must select bodies.

NOTES:

  • The merge parameter applies to bosses, but not to cuts.

  • When the UseFeatScope parameter is set to FALSE, it applies to all bodies including new bodies placed before the feature in the FeatureManager design tree.

  • The UseAutoSelect parameter applies to the existing bodies only.

Examples

IModelDoc2.IFeatureManager.IFeatureExtrusion(sd As Boolean, flip As Boolean, dir As Boolean, t1 As Long, t2 As Long, d1 As Double, d2 As Double, dchk1 As Boolean, dchk2 As Boolean, ddir1 As Boolean, ddir2 As Boolean, dang1 As Double, dang2 As Double, offsetReverse1 As Boolean, offsetReverse2 As Boolean, translateSurface1 As Boolean, translateSurface2 As Boolean, merge As Boolean, useFeatScope As Boolean, useAutoSelect As Boolean) As feature

 

ModelDoc2.FeatureManager.FeatureCut(sd As Boolean, flip As Boolean, dir As Boolean, t1 As Long, t2 As Long, d1 As Double, d2 As Double, dchk1 As Boolean, dchk2 As Boolean, ddir1 As Boolean, ddir2 As Boolean, dang1 As Double, dang2 As Double, offsetReverse1 As Boolean, offsetReverse2 As Boolean, translateSurface1 As Boolean, translateSurface2 As Boolean, normalCut As Boolean, useFeatScope As Boolean, useAutoSelect As Boolean) As feature

In the following example, three solid bodies exist: Extrude1, Extrude2, and Extrude3. To create a through-all cut through Extrude1 and Extrude3, you could do something like the following. Notice the use of the mark parameter.

Part.ModelDocExtension.SelectByID2 "Sketch5", "SKETCH", 0, 0, 0, 1, 0, Nothing, swSelectOptionDefault   'cut profile

Part.ModelDocExtension.SelectByID2 "Extrude3", "SOLIDBODY", 0, 0, 0, 1, 1, Nothing, swSelectOptionDefault   'body to affect

Part.ModelDocExtension.SelectByID2 "Extrude1", "SOLIDBODY", 0, 0, 0, 1, 1, Nothing, swSelectOptionDefault   'body to affect

Part.FeatureManager.FeatureCut 1, 0, 0, 1, 0, 0.058, 0.058, 0, 0, 0, 0, 0.01, 0.01, 0, 0, 0, 0, 0, 1, 0 'use feature scope, do not use Autoselect

You can observe this by recording a macro and playing it back.

In the following example, again three solid bodies exist: Extrude1, Extrude2, and Extrude. However, in this example, a through-all extrusion boss is created and merges with Extrude1 and Extrude3. Notice the use of the mark parameter and that merge is set to TRUE.  

Part.ModelDocExtension.SelectByID2  "Sketch4", "SKETCH", 0, 0, 0, 1, 0, Nothing, swSelectOptionDefault   boss profile

Part.ModelDocExtension.SelectByID2  "Extrude3", "SOLIDBODY", 0, 0, 0, 1, 1, Nothing, swSelectOptionDefault   'body to affect

Part.ModelDocExtension.SelectByID2  "Extrude1", "SOLIDBODY", 0,0,0, 1, 1, Nothing, swSelectOptionDefault   'body to affect

Part.FeatureManager.FeatureExtrusion 1, 0, 1, 1, 0, 0.047, 0.047, 0, 0, 0, 0, 0.01, 0.01, 0, 0, 0, 0, 1, 1, 0 'merge, use feature scope, do not use Autoselect

Back to top

Modifying the definition of solid features that use feature scope

The IExtrudeFeatureData2, ILoftFeatureData, IRevolveFeatureData2, ISweepFeatureData, and IThickenFeatureData have methods and properties that support multibody parts:

Methods:

  • GetFeatureScopeBodiesCount

  • IGetFeatureScopeBodies

  • ISetFeatureScopeBodies

Properties:

  • AutoSelect (VARIANT_BOOL)

  • FeatureScope (VARIANT_BOOL)

  • FeatureScopeBodies (VARIANT array of bodies)

When you get or set FeatureScopeBodies, that feature then affects all bodies in that array. Make sure that any bodies that you set in this array exist and that IBody2 objects are valid when the feature is in its rolled-back state (after AccessSelections is called). If the bodies are not available, then you might have to reorder features in the FeatureManager design tree to achieve the desired result.

Also, if FeatureScope is set to false or merge is set to true, then GetFeatureScopeBodiesCount returns 0 and FeatureScopeBodies is an empty array.

Back to top



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:   Programming Multibody Parts
*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) 2013 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.