Sie sind auf Seite 1von 18

VBA 4

VBA with SOLIDWORKS


(Base Solid Model)

6
Lecture 1

Basic Procedure
1. Set
1
S t the
th plane
l
2. Draw the profiles using sketch
entities
titi
3. Create the base model
(Step 1 and 2: has learnt from previous
slide)

Lecture 6

Extruded: Refresher

Lecture 6

Extruded Base Model


pFeat = FeatureManager.FeatureExtrusion2
FeatureManager FeatureExtrusion2 ( sd,
sd flip,
flip dir,
dir t1,
t1
t2, d1, d2, dchk1, dchk2, ddir1, ddir2, dang1, dang2,
offsetReverse1, offsetReverse2, translateSurface1,
g , useFeatScope,
p , useAutoSelect,,
translateSurface2,, merge,
t0, startOffset, flipStartOffset )
sd:
flip

TRUE: single ended FALSE: double ended


TRUE to flip the direction to cut (not applicable for
base mode)
dir
TRUE to flip the direction to extrude
t1
t2
Lecture 6

pFeat = FeatureManager.FeatureExtrusion2 ( sd, flip, dir, t1, t2,


d1, d2, dchk1, dchk2, ddir1, ddir2, dang1, dang2,
offsetReverse1, offsetReverse2, translateSurface1,
translateSurface2 merge,
translateSurface2,
merge useFeatScope,
useFeatScope useAutoSelect,
useAutoSelect t0,
t0
startOffset, flipStartOffset )

d1 in meters

ddir1:

TRUE: inward
FALSE: outward

dchk1: TRUE for


drafting

dang1: draft angle

d2 in meters

ddir2:

dchk2: TRUE for


drafting

TRUE: inward
FALSE: outward

dang2: draft angle


Lecture 6

Parameters: default values


pFeat = FeatureManager.FeatureExtrusion2 ( sd, flip, dir, t1,
t2, d1, d2, dchk1, dchk2, ddir1, ddir2, dang1, dang2,
offsetReverse1, offsetReverse2, translateSurface1,
translateSurface2, merge, useFeatScope, useAutoSelect,
t0, startOffset, flipStartOffset )
OffsetReverse1
trabslateSurface1
Merge
useAutoSelect:
startOffset:

False,
False,
False
False,
False
0

OffsetReverse2
translateSurface2
useFeatScope:
t0
flipStartOffset:

False,
False,
False
False,
0
False

Set base = Part.FeatureManager.FeatureExtrusion2(True,


False, False, 0, 0, 10, 0, False, False, False, False, 0, 0, False,
False, False, False, False, False, False, 0, 0, False)
Example: extrude.swp
Lecture 6

Revolved Base Model


Base Profile

Axis of revolution

Dim line1, line2, line3, line4, consline As Object


Set line1 = Part.CreateLine2(5, 5, 0, 5, -5, 0)
Set line2 = Part
Part.CreateLine2(5,
CreateLine2(5 -5
5, 0,
0 -5
5, -5
5, 0)
Set line3 = Part.CreateLine2(-5, -5, 0, -5, 5, 0)
Set line4 = Part.CreateLine2(-5, 5, 0, 5, 5, 0)
Set consline = Part.CreateLine2(10, 5, 0, 10, 5, 0)
consline.ConstructionGeometry = True

Lecture 6

Revolved Base Model

5
10

Lecture 6

Revolved Base Model


retVal = FeatureManager.FeatureRevolve
FeatureManager FeatureRevolve ( angle,
angle reverseDir,
reverseDir
angle2, revType, options, merge, useFeatScope, useAutoSel )
revType:
swRevolveOneDirection
swRevolveTypeMidPlane

Angle1: in radian

swRevolveTypeTwoDirection
Etc (refer to online help)

reverseDir:
True: reverse the
direction
False: not

Other parameters
Angle2: in radian

Lecture 6

Options:

Merge:

False

useFeatScope:

False

useAutoSel:

False
9

revolve.swp

Revolved Base Model


Dim base As Object
Set base = Part.FeatureManager.FeatureRevolve
(3.14, False, 0, swRevolveOneDirection, 0, False,
F l e False)
False,
F l e)

Lecture 6

10

Thin Feature
FeatureRevolveThin
(additional parameters:
thickness 1 and thickness 2)

FeatureExtrusion2
(additional parameters:
thickness
hi k
1 and
d thickness
hi k
2)
Lecture 6

11

Create Sub Component


Procedure
P
d
1. Select the face where the profiles
t be
to
b drawn
d
2. Draw the profiles
Similar to the profile creation in sketch.

3.

Create the model to cut or extrude

Lecture 6

12

Select the face to create the plane


1 Select the face
1.
boolstatus = Part.Extension.SelectByID2("", "FACE", 1,
1, 0, False, 0, Nothing, 0)
2. Create the plane
Part.SketchManager.InsertSketch True
*

The coordinate set in the selection set must be the point


on the intended face.
fa e

Lecture 6

13

Create the cut or extruded feature


1 Extruded
1.
E t d d ffeature:
t
use the FeatureExtrusion2 command

2. Cut feature: use FeatureCut


command
pFeat = FeatureManager.FeatureCut ( sd, flip, dir, t1, t2, d1,
d2, dchk1, dchk2, ddir1, ddir2, dang1, dang2, offsetReverse1,
offsetReverse2 translateSurface1
offsetReverse2,
translateSurface1, translateSurface2,
translateSurface2
normalCut, useFeatScope, useAutoSelect )
* all the parameters are similar to FeatureExtrusion2
Lecture 6

14

Example: cut feature


boolstatus = Part.Extension.SelectByID2(
Part Extension SelectByID2("", "FACE"
FACE , 1
1, 1
1, 0,
0 False,
False 0,
0
Nothing, 0)
Part.SketchManager.InsertSketch True
Dim line2, line3, line4, line5, base2 As Object
Set line2 = Part.CreateLine2(-2, 1, 0, 2, 1, 0)
Set line3 = Part.CreateLine2(2, 1, 0, 2, 3, 0)
Set line4 = Part
Part.CreateLine2(2,
CreateLine2(2 3,
3 0,
0 -2,
2 3,
3 0)
Set line5 = Part.CreateLine2(-2, 3, 0, -2, 1, 0)
Set base2 = Part.FeatureManager.FeatureCut(True, False, False,
swEndCondThroughAll, 0, 0, 0, False, False, False, False, 0, 0, False,
False, False, False, 0, 1, 1)
Note: when swEndCondThroughAll (t1) is used, the distance to cut can be
set to 0.
Lecture 6

15

Shell
Part.SketchRectangle
g -0.04,, -0.04,, 0,, 0.04,, 0.04,, 0,, 1
Part.FeatureManager.FeatureExtrusion2 True, False, False, 0, 0, 0.04, 0,
False, False, False, False, 0, 0, False, False, False, False, False, False,
False, 0, 0, False
boolstatus = Part.Extension.SelectByID2("", "FACE", 0, 0.04, 0, False, 0,
Nothing 0)
Nothing,
Part.InsertFeatureShell 0.005, False

Lecture 6

16

Assignment 2
W
Write
it th
the subroutine
b
ti
that
th t will
ill draw
d
the linkages for the projects. The
subroutine will need the length,
length angle
of orientation and insertion points.

Lecture 6

17

Major Project
Y
Your ttask
k is
i to
t write
it a program to
t
builtSet the point , determine
whether the body can reachable and
angle required.

Lecture 6

18

Das könnte Ihnen auch gefallen