Mirror Components Example (VB.NET)
This example shows how to mirror components in an assembly.
'----------------------------------------------------------------------------
' Preconditions: Open:
' install_dir\samples\tutorial\advdrawings\98food
processor.sldasm
'
' Postconditions:
' 1. Creates reference plane, PLANE4.
' 2. Creates feature, MirrorComponent1, that mirrors six assembly
' components.
' 3. The mirror components are saved to files with suffix, "_TestMirror"
' in the model folder.
' 4. Inspect the folder.
'
' NOTE: Because the model is used elsewhere, do not save changes to it.
'
---------------------------------------------------------------------------
Imports
SolidWorks.Interop.sldworks
Imports
SolidWorks.Interop.swconst
Imports
System.Runtime.InteropServices
Imports
System
Partial
Class
SolidWorksMacro
Sub
main()
Dim
swModel As
ModelDoc2
swModel = swApp.ActiveDoc
Dim
boolstatus As
Boolean
boolstatus = swModel.Extension.SelectByID2("",
"FACE",
0.104250921669188, -0.000236987012272039, -0.0597199999999418,
True, 0,
Nothing, 0)
Dim
myRefPlane As
RefPlane
myRefPlane = swModel.FeatureManager.InsertRefPlane(8,
0.01, 0, 0, 0, 0)
Dim
swAssem As
AssemblyDoc
swAssem = swModel
Dim
compsToInstance As
Object
compsToInstance =
Nothing
Dim
filenames As
Object
filenames =
Nothing
Dim
location As
String
location =
""
Dim
nameModifierType As
swMirrorComponentNameModifier_e
nameModifierType =
swMirrorComponentNameModifier_e.swMirrorComponentName_Suffix
Dim
nameModifier As
String
nameModifier =
"_TestMirror"
Dim
mirrorPlane As
Feature
mirrorPlane = swAssem.FeatureByName("PLANE4")
Dim
compsToMirror(0 To
5) As
Component2
compsToMirror(0) = swAssem.GetComponentByName("gear-
caddy-1")
compsToMirror(1) = swAssem.GetComponentByName("middle-gear-1")
compsToMirror(2) = swAssem.GetComponentByName("shaft
gear-1")
compsToMirror(3) = swAssem.GetComponentByName("middle-gear
plate-1")
compsToMirror(4) = swAssem.GetComponentByName("base
plate-1")
compsToMirror(5) = swAssem.GetComponentByName("shaft
gear insert-1")
Dim
orientations As
Object
orientations =
Nothing
Dim
orientAboutCoM As
Boolean
orientAboutCoM =
True
Dim
createDerivedConfigs As
Boolean
createDerivedConfigs =
False
Dim
importOptions As
Integer
importOptions =
swMirrorPartOptions_e.swMirrorPartOptions_ImportSolids +
swMirrorPartOptions_e.swMirrorPartOptions_ImportCustomProperties +
swMirrorPartOptions_e.swMirrorPartOptions_ImportCosmeticThreads
Dim
breakLinks As
Boolean
breakLinks =
False
Dim
preserveZAxis As
Boolean
preserveZAxis =
True
Dim
vResult As
Object
vResult = swAssem.MirrorComponents2(mirrorPlane,
compsToInstance, orientations, orientAboutCoM, (compsToMirror), _
createDerivedConfigs, _
filenames, nameModifierType, nameModifier, location, _
importOptions, breakLinks, preserveZAxis)
End
Sub
Public
swApp As
SldWorks
End
Class