×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

VBA create chanfer by selected faces

VBA create chanfer by selected faces

VBA create chanfer by selected faces

(OP)
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 --> vb.net

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

RE: VBA create chanfer by selected faces

(OP)
Problem found...

CODE --> vb.net

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

RE: VBA create chanfer by selected faces

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

RE: VBA create chanfer by selected faces

(OP)
Unless chamfer1 was already initialized... that's why I was looking to the mistake...

Tiago Figueiredo
Tooling Engineer

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources