Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA create chanfer by selected faces

Status
Not open for further replies.

TiagoFigueiredo

Industrial
May 22, 2013
494
PT
I'm trying to create a chamfer using pre selected faces in a macro. But i'm no having much sucess

what I have tried:

The faces are previously selected.

Code:
chamfer2 = shapeFactory1.AddNewChamfer(reference1, catTangencyChamfer, catLengthAngleChamfer, catNoReverseChamfer, 1, 45.0#)
        Dim Num_Faces As Integer = selection1.count
        Dim Faces_ref(Num_Faces)
        For i = 1 To Num_Faces


            Dim MyBRepName = (selection1.Item(i).Value.Name)

            MyBRepName = Replace(MyBRepName, "Selection_", "")
            MyBRepName = Left(MyBRepName, InStrRev(MyBRepName, "));"))
            MyBRepName = MyBRepName + ");WithPermanentBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)"

            MsgBox(MyBRepName)
            reference1 = Part1.CreateReferenceFromName(MyBRepName)

            chamfer1.AddElementToChamfer(reference1)

        Next

the error appears here:

chamfer1.AddElementToChamfer(reference1)


Tiago Figueiredo
Tooling Engineer
 
Replies continue below

Recommended for you

Problem found...

Code:
chamfer2 = shapeFactory1.AddNewChamfer(reference1, catTangencyChamfer, catLengthAngleChamfer, catNoReverseChamfer, 1, 45.0#)
        Dim Num_Faces As Integer = selection1.count
        Dim Faces_ref(Num_Faces)
        For i = 1 To Num_Faces


            Dim MyBRepName = (selection1.Item(i).Value.Name)

            MyBRepName = Replace(MyBRepName, "Selection_", "")
            MyBRepName = Left(MyBRepName, InStrRev(MyBRepName, "));"))
            MyBRepName = MyBRepName + ");WithPermanentBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)"

            MsgBox(MyBRepName)
            reference1 = Part1.CreateReferenceFromName(MyBRepName)

            chamfer1.AddElementToChamfer(reference1)

        Next

It should be

chamfer2.AddElementToChamfer(reference1)


Not Chamfer1...

I'm really becoming dyslexic...

Tiago Figueiredo
Tooling Engineer
 
I think the error messages are quite different in your case:
1. chamfer1 is not initialized (=nothing --> "Object required")
and
2. method .AddElementToChamfer fails.

Unless chamfer1 was already initialized :)

Calin
 
Unless chamfer1 was already initialized... that's why I was looking to the mistake...

Tiago Figueiredo
Tooling Engineer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top