Quantcast
Channel: Manufacturing DevBlog
Viewing all articles
Browse latest Browse all 518

Create Chamfer Feature in Part Document

$
0
0

By Xiaodong Liang

API provides the corresponding methods of UI to create chamfer feature.

ChamferFeatures.AddUsingDistance: creates a new ChamferFeature defined by a specified distance. The required arguments are the distance and the edges.

clip_image001

ChamferFeatures.AddUsingDistanceAndAngle: creates a new ChamferFeature that is defined by a distance and at a specified angle to an input face. The required arguments are referred face, edges, distance and angle.

clip_image002

ChamferFeatures.AddUsingTwoDistances: creates a new ChamferFeature that is defined by two distances. The required arguments are referred face, edges, distance one and distance two.

clip_image003

The code below demos the three methods. It assumes it is a part document. A face (with at least four edges) is selected.

    Sub createChamferInPart()

 

        Dim oDoc As PartDocument

        oDoc = ThisApplication.ActiveDocument

 

        Dim oDef As PartComponentDefinition

        oDef = oDoc.ComponentDefinition

 

        'selected face

        Dim oSelectedFace As Face

        oSelectedFace = oDoc.SelectSet(1)

 

        Dim oEdgeCol As EdgeCollection

        oEdgeCol = ThisApplication.TransientObjects.CreateEdgeCollection()

 

        'method 1: creates a new ChamferFeature defined by 0.1 inch.

        oEdgeCol.Add oSelectedFace.Edges(1)

        oEdgeCol.Add oSelectedFace.Edges(2)

 

        Call oDef.Features.ChamferFeatures.AddUsingDistance(oEdgeCol,

                                                                                                "0.1 in")

 

        'method 2: creates a new ChamferFeature that is defined 
         'by 0.2 inch and 30 degree
        oEdgeCol.Clear()

        oEdgeCol.Add oSelectedFace.Edges(3)

        Call oDef.Features.ChamferFeatures.AddUsingDistanceAndAngle

                       (oEdgeCol,

                        oSelectedFace,

                        "0.2 in",

                          0.5233)

 

        'method 3: creates a new ChamferFeature that is defined
         ' by 0.1 inch and 0.2 inch
        oEdgeCol.Clear()

        oEdgeCol.Add oSelectedFace.Edges(4)

        Call oDef.Features.ChamferFeatures.AddUsingTwoDistances(oEdgeCol,

                                                         oSelectedFace,

                                                         "0.1 in",

                                                         "0.2 in")

 

    EndSub

 


Viewing all articles
Browse latest Browse all 518

Trending Articles