| Alibre API Programming Introduction - Creating a Sketch |
|
|
Page 6 of 9 Creating A SketchFirst let's get a design plane to work with. Because we're making a cube that's centered on the origin, we can just use the first plane (probabaly XY-Plane). There are tips for tracking down the localized names of planes in the API documentation, but for now we'll just stick with this. We'll start by getting IADDesignSession interface from the part. ' Get the first design plane Dim design As IADDesignSession = part Dim plane As IADDesignPlane = = design.DesignPlanes.Item(0) ' first plane // Get the first design plane IADDesignSession design = (IADDesignSession)part; IADDesignPlane plane = design.DesignPlanes.Item(0); // first plane Now we'll add a sketch based on the plane, give it an appropriate name. ' Add a sketch Dim sketch As IADSketch _ = part.Sketches.AddSketch(Nothing, plane, "Square") // Add a sketch IADSketch sketch = part.Sketches.AddSketch(null, plane, "Square"); Now draw the square. Note that we must call BeginChange() and EndChange(). These methods in effect "activate" the sketch for 2D drawing. You can ALT-TAB over to the Alibre Design part during all of this and actually see it working on these commands. ' Draw the square ' allow us to center about the origin Dim offset As Double = dimension / 2D Call sketch.BeginChange() sketch.Figures.AddRectangle(-offset, _ -offset, offset, offset) Call sketch.EndChange() // Draw the square // allow us to center about the origin double offset = dimension / 2D; sketch.BeginChange(); sketch.Figures.AddRectangle(-offset, -offset, offset, offset); sketch.EndChange(); |
|
| Last Updated ( Monday, 28 July 2008 00:36 ) |
