Creating a Simplified Camshaft
Creating a Simplified Camshaft
Interfaces Camshaft
The cam shaft is made of five bearings, four cam sets, and a
driving wheel.
The bearings are made of a pad and a pattern that duplicates
the pad. Each cam set is made of two identical cams separated
by a pin. The cam sets are each rotated of 90 degrees about the
camshaft axis. The driving wheel is a simple cylinder.
CAAPriCreateCamshaft is launched in CATIA [1]. No open
document is needed.
1. Prolog
2. Main program
3. Creating the Bearings
4. Creating a Cam Set
5. Creating a Cam
6. Creating the Pin Between two Cams and the Driving
Wheel
Prolog
...
'Number Of Cylinders
' ------------------
Dim iNumberOfCylinders As Integer
' Pi definition
' -------------
Dim dPi As Double
' -- Part
Dim oPart As Part
Main program
...
Sub CATMain()
End Sub
...
The main program initializes the parameters (lengthes are
initialized in mm), and calls different Subs:
The main program prompts you the task it will do before doing
it using the msgbox function, and when its done, updates the
part to compute the resulting geometry, and reframes the
display before prompting you the next task.
...
Sub CreatePatternBearing()
...
The pad to be patterned is a cylinder defined using a sketch
that is first added to the sketch collection as an empty object.
Then it is edited using the 2D factory object held by the sketch
object between the calls to the OpenEdition and CloseEdition
methods. The sketch is made up of a circle of the YZ plane
whose center is the plane origin, and whose radius is
iBearingDiam/2, thanks to the CreateClosedCircle method of the
2D factory object. The sketch is then used to create the pad
using the AddNewPad method of the shape factory object
available from the part object itself.
...
' Creating the pattern
' --------------------
End Sub
...
Once the pad is created, it can be patterned using a rectangular
pattern created thanks to the AddNewRectPattern method of
the shape factory object. The pattern parameters are:
...
Sub CreateCamSet(angle)
End Sub
...
CreateCamSet creates the camset according to its angle about
the shaft. It calls CreateCam, CreateCylinder, and CreateCam
again to create the first cam, the pin between the two cams of
the set, and the second cam respectively. iCurrentLevel is
updated after the two calls to CreateCam to correctly position
the next object. CreateCylinder updates it itself.
Creating a Cam
...
Sub CreateCam(angle)
...
' Create a sketch
' ---------------
Set oCurrentSketch = oPartBody.Sketches.Add ( oPlaneYZ )
This sketch shows how the lines are created using these
coordinates, for an angle of 30 degrees. Their points are located
on the circles where perpendicular diameters to the circle
center direction cross the circles. The circles shown here are the
support circles or the circle arcs.
...
Dim dRad1 As Double
dRad1 = dRad - dPi/4
...
' Get references from elements to constraint
' ------------------------------------------
oPart.CreateReferenceFromObject(oCurrentCircle1.StartPoint)
oPart.CreateReferenceFromObject(oCurrentCircle2.StartPoint)
...
' Create constraints
' ------------------
Dim oConstraints As Constraints
Set oConstraints = oCurrentSketch.Constraints
Dim oConstraint As Constraint
...
The constraint collection is retrieved from the sketch, and a
current constraint object is created to be used throughout the
constraint creation step. First, the two support circles of the two
circle arcs are set as non modifiable using a fix constraint, that
is they can't move, or their radius can't change, thanks to the
AddMonoEltCst method to which the catCstTypeReference
constraint type, for fix constraint, is passed, along with the
reference to the circle. This is shown by the tangency symbol.
...
' -- Tangency Line1 Circle1
Set oConstraint =
oConstraints.AddBiEltCst(catCstTypeTangency, _
oRefLine1, _
oRefCircle1)
...
A tangency constraint is set between the first line segment and
the first circle arc, thanks to the AddBiEltCst method to which
the catCstTypeTangency constraint type, for tangency
constraint, is passed, along with the references to the line
segment and the circle arc. This is shown by the tangency
symbol.
...
' -- Tangency Line1 Circle2
Set oConstraint =
oConstraints.AddBiEltCst(catCstTypeTangency, _
oRefCircle2, _
oRefLine1)
...
Another tangency constraint is set between the first line
segment and the second circle arc.
...
' -- Coincidence Circle1 Start Point Line1 Start Point
Set oConstraint =
oConstraints.AddBiEltCst(catCstTypeOn, _
oRefCircle1StartPt, _
oRefLine1StartPt)
...
A coincidence constraint is set between the first line segment
and the first circle arc, thanks to the AddBiEltCst method to
which the catCstTypeOn constraint type, for coincidence
constraint, is passed, along with the references to the line
segment and the circle arc. This is shown by the coincidence
symbol. Now the geomentric object are relimited.
...
' -- Coincidence Circle2 End Point Line1 End Point
Set oConstraint = oConstraints.AddBiEltCst(catCstTypeOn,
_
oRefCircle2EndPt, _
oRefLine1EndPt)
...
Another coincidence constraint is set between the first line
segment and the second circle arc.
The first line segment now connects and is tangent to the two
circle arcs. The same applies to the second one
...
' -- Tangency Line2 Circle1
Set oConstraint =
oConstraints.AddBiEltCst(catCstTypeTangency, _
oRefLine2, _
oRefCircle1)
oCurrentSketch.CloseEdition
End Sub
...
When the constraints are set, the sketch edition is closed, and
the pad relying on this sketch can be created using the
AddNewPad method.
...
Sub CreateCylinder(thickness, radius)
End Sub
...
A sketch is added to the sketch collection of the the part body,
and the 2D factory is retrieved by opening the sketch edition. A
closed circle is created thanks to the CreateClosedCircle
method using the radius passed as argument and whose center
is the YZ plane coordinate system origin. Then the sketch
edition is closed, and the pad is created using the AddNewPad
method of the shape factory object aggregated to the part
object. It uses the just created sketch, and sets the pad height
to current level plus the thickness. At this moment, the created
pad extends from the YZ plane to the iCurrentLevel + thickness
abscissa. This is far too much. The SecondLimit property of the
pad object enables the pad to be resized. The value of the
dimension object of this second limit is set to the opposite to
the current level. The second limit value is counted positive
along the negative abscissa of the pad extrusion axis. This is
why the opposite of the current level is taken into account. This
makes the pad's second face, that is, the second one parallel to
the sketch, with the top face of the previous one, that is, the
face of the last bearing. Below are two screen shots that show
the effect of these two successive pad creation instructions.
Another way of coding could be:
...
Dim oPad As Pad
Set oPad = oPart.ShapeFactory.AddNewPad
( oCurrentSketch, thickness )
oPad.FirstLimit.Dimension.Value = iCurrentLevel +
thickness
oPad.SecondLimit.Dimension.Value = iCurrentLevel*-1
...
This is a more natural way to create the pad using its actual
thickness, but requests three instructions instead of two.
Though the pad is created using its actual thickness, it extends
from the YZ plane to the point of thickness abscissa. Its first
limit, then its second limit are set. Below are three screen shots
that show the effect of these three successive pad creation
instructions.
[Top]
In Short
This use case has shown how to create a simplified camshaft using
the PartInterfaces framework objects, namely the Pad and the
Pattern objects. The Sketch and Constraint objects are also used to
create the sketch on which the cam pads rely. The use of Reference
objects retrieved from the geometric object is shown to be used to
create the pattern and the constraints. In addition, this use case
shows how to organize a macro with Subs that can be called several
times during the macro execution.
[Top]
References