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!

CAT VBA Corner Parametrization Automation

Status
Not open for further replies.

Portolon

Automotive
May 30, 2011
10
BR
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:

corner_ofucfg.png


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#,[highlight #FCE94F] 1, 1,[/highlight] True)
hybridShapeCorner1.DiscriminationIndex = 1
hybridShapeCorner1.BeginOfCorner = 1
[highlight #FCE94F]hybridShapeCorner1.FirstTangentOrientation = 1[/highlight]
[highlight #FCE94F]hybridShapeCorner1.SecondTangentOrientation = 1[/highlight]
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#,[highlight #FCE94F] 1, 1,[/highlight] True)
hybridShapeCorner2.DiscriminationIndex = 1
hybridShapeCorner2.BeginOfCorner = 1
[highlight #FCE94F]hybridShapeCorner2.FirstTangentOrientation = 1[/highlight]
[highlight #FCE94F]hybridShapeCorner2.SecondTangentOrientation = 1[/highlight]
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#, [highlight #FCE94F]-1, -1,[/highlight] True)
hybridShapeCorner4.DiscriminationIndex = 1
[highlight #FCE94F]hybridShapeCorner4.BeginOfCorner = 2[/highlight]
[highlight #FCE94F]hybridShapeCorner4.FirstTangentOrientation = -1[/highlight]
[highlight #FCE94F]hybridShapeCorner4.SecondTangentOrientation = -1[/highlight]
hybridShapeFactory1.GSMVisibility reference7, 0
hybridShapeFactory1.GSMVisibility reference8, 0
hybridBody1.AppendHybridShape hybridShapeCorner4
part1.InWorkObject = hybridShapeCorner4
part1.Update
 
Replies continue below

Recommended for you

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 AB[sub]0/1[/sub] = BC[sub]0/1[/sub] or AB[sub]0/1[/sub] = BC[sub]0/1[/sub]

hope this help

[highlight #D3D7CF]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.[/highlight]

Eric N.
indocti discant et ament meminisse periti
 
Hey Eric N., thanks for your suggestion.
I'm gonna try this.

Portolon
 
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

*****

corner_qaxsir.png
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top