You need to be logged in to view this content. Please login or become a member.

<<  Prev   |   Index   |   Next  >>

Description

In this lesson you will learn how to create and dimension sketch entities, as well as traverse existing sketch segments.

Notes

In a sketch, you are always looking normal to the X-Y plane of the sketch, even if the plane or planar face that the sketch resides on is in a different plane. So, for example, if you created a sketch on the XZ plane, when you used ISketchManager::CreateLine, you would specify the XYZ coordinates for the start and end points relative to the sketch itself, NOT relative to the XZ plane. If you need to convert between coordinate systems, you will need to use transforms. See the API Help example “Transform Sketch to Model Example (VBA)”. This transformation is not true for dimension placement, however. When using an API call like IModelDoc2::AddDimension2, the standard part coordinate arguments still apply.

You can disable graphics updating (and therefore speed up your macros) using IModelView::EnableGraphicsUpdate.

If you know the fully qualified name of the dimension (e.g., “D1@Sketch1”) you can also use IModelDoc2::Parameter::SystemValue to change the dimension value. See the API Help Example “Change Dimension Example (VBA)”. However, a better way to change a dimension value is by using IDimension::GetSystemValue3 and IDimension::SetSystemValue3 if you can get access to the IDimension object. The IDimension object is accessed through IDisplayDimension::GetDimension2. This latter technique allows you specify which configurations the dimension change applies to.

If you are trying to add sketch constraints and the sketch entities were selected with methods like ISketchSegment::Select4 or ISketchPoint::Select4, IModelDoc2::SketchAddConstraints will not add the constraints. Instead you will need to use ISldWorks::RunCommand using enumeration values like “swCommands_Add_Constraint_Coinc” for the CommandID argument. Alternative, you could use the ISketchRelationManager to add constraints.

Even though this lesson is in the “part” unit, the techniques demonstrated transfer directly to assemblies and parts as well. For that reason, I have decided not to talk about the IPartDoc interface until the third lesson of this unit.

Lesson Files

Lesson 4.1 sketch creation code
Lesson 4.1 fully-define sketch code
Code snippets