×
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

CAT VBA Corner Parametrization Automation

CAT VBA Corner Parametrization Automation

CAT VBA Corner Parametrization Automation

(OP)
Hi,

I'm working on a macro to automate the corner creation in a sharp-edge geometry.
From previous attempts, I noticed that the parameters of the corner can vary, according to the references employed to create the corner - please check the code examples down below.

Then I'm looking for information on how CATIA sets the parameters to create the corner, in order to include this logic in my macro. Then, the macro shall be able to add corners like seen in the image:



Does anyone know how to automate the parametrization of the corner?

Thanks in advance,
Portolon
-----
Code Examples:

These parameters were recorded when a corner was added manually between two lines:

Dim hybridShapeCorner1 As HybridShapeCorner
Set hybridShapeCorner1 = hybridShapeFactory1.AddNewCorner(reference1, reference2, Nothing, 12#, 1, 1, True)
hybridShapeCorner1.DiscriminationIndex = 1
hybridShapeCorner1.BeginOfCorner = 1
hybridShapeCorner1.FirstTangentOrientation = 1
hybridShapeCorner1.SecondTangentOrientation = 1
hybridShapeFactory1.GSMVisibility reference1, 0
hybridShapeFactory1.GSMVisibility reference2, 0
hybridBody1.AppendHybridShape hybridShapeCorner1
part1.InWorkObject = hybridShapeCorner1


And these parameters were recorded when a corner were added between a corner and a line:

Dim hybridShapeCorner2 As HybridShapeCorner
Set hybridShapeCorner2 = hybridShapeFactory1.AddNewCorner(reference3, reference4, Nothing, 12#, 1, 1, True)
hybridShapeCorner2.DiscriminationIndex = 1
hybridShapeCorner2.BeginOfCorner = 1
hybridShapeCorner2.FirstTangentOrientation = 1
hybridShapeCorner2.SecondTangentOrientation = 1
hybridShapeFactory1.GSMVisibility reference3, 0
hybridShapeFactory1.GSMVisibility reference4, 0
hybridBody1.AppendHybridShape hybridShapeCorner2
part1.InWorkObject = hybridShapeCorner2
part1.Update


And another example of parameters from a corner were added between a corner and a line:

Dim hybridShapeCorner4 As HybridShapeCorner
Set hybridShapeCorner4 = hybridShapeFactory1.AddNewCorner(reference7, reference8, Nothing, 12#, -1, -1, True)
hybridShapeCorner4.DiscriminationIndex = 1
hybridShapeCorner4.BeginOfCorner = 2
hybridShapeCorner4.FirstTangentOrientation = -1
hybridShapeCorner4.SecondTangentOrientation = -1
hybridShapeFactory1.GSMVisibility reference7, 0
hybridShapeFactory1.GSMVisibility reference8, 0
hybridBody1.AppendHybridShape hybridShapeCorner4
part1.InWorkObject = hybridShapeCorner4
part1.Update

RE: CAT VBA Corner Parametrization Automation

my guess is that the tangent orientation is linked with the orientation of the curve(line).

create 3 points ABC then line AB and line BC anc line CB

record macro doing corner AB-BC and AB-CB

if I am corret you should be able to code properly if you understand the curve orientation which you could get by creating point on curve with ratio 0 or 1 and checking if AB0/1 = BC0/1 or AB0/1 = BC0/1

hope this help

ps keep your post together I will flag the other one as duplicate to get it removed or closed so activity will continue on this one only.

Eric N.
indocti discant et ament meminisse periti

RE: CAT VBA Corner Parametrization Automation

(OP)
Hey Eric N., thanks for your suggestion.
I'm gonna try this.

Portolon

RE: CAT VBA Corner Parametrization Automation

(OP)
Another line of investigation gave a better answer: joining the entities and then adding the corner.
The created join will be the only input for the corner; mark "Corner On Vertex" to complete the operation, as shown in the picture down below.

The following code were applied to automate the operation. The geometry under treatment (different from that of the picture), has sharp and round corners; using the join command, only the sharp corners were converted to round corners, without the need of knowing the parameters of every pair of entities.


For i = 1 To gsCol.Count

Dim GSj As HybridBody
Set GSj = gsCol.Item(i)
Debug.Print GSj.Name

part1.InWorkObject = GSj
part1.Update


'-------------------------------------------------
'Creates HybridShapes collection
'Add the collection to the Join to be created
'-------------------------------------------------

Dim join1 As HybridShapeAssemble

Dim hs1 As HybridShape
Set hs1 = GSj.HybridShapes.Item(2)

Dim hs2 As HybridShape
Set hs2 = GSj.HybridShapes.Item(3)


Set join1 = hsFactory.AddNewJoin(hs1, hs2)

For j = 3 To sel_2.Count

Dim HSi As HybridShape
Set HSi = sel_2.Item(j).Value
join1.AddElement HSi

Next


'-------------------------------------------------
'Add corners
'-------------------------------------------------

Dim corner1 As HybridShapeCorner
Set corner1 = hsFactory.AddNewCorner(join1, Nothing, Nothing, radius, 1, 1, True)

corner1.CornerType = 0
corner1.OnVertex = True
corner1.Compute

corner1.Name = "Corner_" & i

GSj.AppendHybridShape corner1

part1.Update


Next

*****


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