Continue to Site

Welcome to 3DCADForums

Join our CAD community forums where over 25,000 users interact to solve day to day problems and share ideas. We encourage you to visit, invite you to participate and look forward to your input and opinions. Acrobat 3D, AutoCAD, Catia, Inventor, IronCAD, Creo, Pro/ENGINEER, Solid Edge, SolidWorks, and others.

CATIA Macro to create multiple holes

rogerio

New member
Hello,

I fairly new in CATIA macros. I am writing a macro to create multiple holes in CATIA. The macro should work the following way:

1) RivetLines are created in a Geometrical set
2) The Macro should create holes by selecting the RivetLines and a surface.

The problem is that the RivetLines have different Coordinates and I am not able to get their positions with the code. Below is a draft of what I have done.
Please help!


Sub CATMain()

Set documents1 = CATIA.Documents

Set partDocument1 = documents1.Item("Part1.CATPart")

Set part1 = partDocument1.Part

Set shapeFactory1 = part1.ShapeFactory

Set bodies1 = part1.Bodies

Set body1 = bodies1.Item("PartBody")

Set shapes1 = body1.Shapes

Set pad1 = shapes1.Item("Pad.1")

Dim I As Integer
Dim j As Integer

For I = 1 To 10
For j = 1 To 10

Set referencej = part1.CreateReferenceFromBRepName("FSur:(Face:(Brp:(Pad.1;2);None:();Cf11:());WithTemporaryBody;WithoutBuildError;WithInitialFeatureSupport;MonoFond;MFBRepVersion_CXR15)", pad1)

Set holei = shapeFactory1.AddNewHoleFromPoint(12.7, 8.355, 51.633, referencej, 10#)

holei.Type = catSimpleHole

holei.AnchorMode = catExtremPointHoleAnchor

holei.BottomType = catFlatHoleBottom

Set limiti = holei.BottomLimit

limiti.LimitMode = catOffsetLimit

Set lengthi = holei.Diameter

lengthi.Value = 10#

Set hybridBodies1 = part1.HybridBodies

Set hybridBody1 = hybridBodies1.Item("Geometrical Set.2")

Set hybridShapes1 = hybridBody1.HybridShapes

Set hybridShapeLineNormal1 = hybridShapes1.Item("RivetLine.i")

Set referencej = part1.CreateReferenceFromObject(hybridShapeLineNormal1)

holei.SetDirection referencej

holei.ThreadingMode = catSmoothHoleThreading

holei.ThreadSide = catRightThreadSide

lengthi.Value = 6.35
Exit For
Exit For
Next
Next

part1.Update

End Sub
 

Articles From 3DCAD World

Sponsor

Back
Top