Creating a Slot in a sketch and fully constraining them using C#

Creating a Slot in a sketch and fully constraining them using C#

thanigai1311
Participant Participant
383 Views
3 Replies
Message 1 of 4

Creating a Slot in a sketch and fully constraining them using C#

thanigai1311
Participant
Participant

Hi All,

 

I am trying to create a slot hole in an assembly by sketching and extrude cut it using c#.

But when I try to give dimensional and geometric constraints, I cannot fully constrain the drawing to give extrude.

In Sketch, to create the Slot I have tried Sketch entity Enumerator, creating with lines and arcs .

But when I create in the ways that I have mentioned I am not able to completely constrain the sketch.

 

Could you give share a particular process to follow?

 

Thanks in advance.

0 Likes
384 Views
3 Replies
Replies (3)
Message 2 of 4

WCrihfield
Mentor
Mentor

Hi @thanigai1311.  One problem I commonly see when folks draw sketch profiles completely by code, that they intent to extrude, is the lack of 'coincident' constraints at the end points of the geometry, where they meet.  When sketching manually, those are usually implied (created for you as you sketch), but that is not the case when doing it by code...unless you remember one critical little detail.  When drawing the next section of a profile, start with the actual end point 'object' of the last entity, as the start point of your new entity, instead of just the same numerical coordinates as that last entities end point.  And when closing the profile, make sure both ends of that last section are starting and ending with the actual start point / end point objects of the two entities on either side of it, not just the same numerical coordinates.  When you do it that way, that will usually cause those ends to be truly closed, and/or those coincident constraints to be created.  Then the profile will be recognized as closed, which is required.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 4

thanigai1311
Participant
Participant

Hi @WCrihfield but following the procedure that you have mentioned I was not able to completely constraint the sketch
in doing that I not only had to give the geometrical constraints but also the dimensional constraints.

for providing the dimensional constraints, I have to provide the Sketch Entities
but for providing the geometrical constraints I have to provide the sketch lines and sketch arcs.

 

And this is the place I am getting confused with.
Do I have to create the sketch using Sketch entities or with sketch lines and sketch arcs

0 Likes
Message 4 of 4

WCrihfield
Mentor
Mentor

Hi @thanigai1311.  Sorry for the delay.  I've been away on an end of year vacation since my last response here.  This is a complicated one to answer clearly.  The object Type SketchEntity is like a 'base class' that all other sketch geometry falls under (within a 2D sketch), so a SketchLine or SketchArc (and many others) are each also a SketchEntity.  What I usually do is create a variable to hold each individual line, arc, or other type of sketch entity that I create.  If I know I am drawing a line with a specific line of code, I declare the variable As a SketchLine Type object, instead of just a generic SketchEntity Type object, because it is more specific and therefore more useful later (for accessing its specific properties).  Then later, if I need to constrain it, either geometrically, or dimensionally, I know specifically which line that was, and can use it as input, along with being able to use its specific properties to help with any additional object specific inputs that may be needed.

Below are a few of the 'sample' codes provided by Autodesk within their online help area...but they are for VBA, instead of iLogic.  The first one creates a dimensional constraint within, while the other two create geometrical constraints within.  Not really that great of examples, but they may help a little.

Create sketch elliptical arc 

Sketch Spline 

Create SketchedSymbol Definition 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes