Language="VBSCRIPT"

Sub CATMain()

Dim partDocument1 As Document
Set partDocument1 = CATIA.ActiveDocument

Dim part1 As Part
Set part1 = partDocument1.Part

Dim shapeFactory1 As Factory
Set shapeFactory1 = part1.ShapeFactory

Dim bodies1 As Bodies
Set bodies1 = part1.Bodies

Dim body1 As Body
Set body1 = bodies1.Item("PartBody")

Dim shapes1 As Shapes
Set shapes1 = body1.Shapes

' check if the part is updated because the hole can be created only if the part is updated 

Dim status As Boolean
status = part1.IsUpToDate(body1) 
if ( status ) then 
	msgbox " The part is updated : hole creation is possible" 

	Dim pad1 As Shape
	Set pad1 = shapes1.Item("Pad.1")

	Dim reference1 As Reference
	Set reference1 = part1.CreateReferenceFromBRepName("FSur:(Face:(Brp:(Pad.1;2);None:());WithTemporaryBody;WithoutBuildError;WithInitialFeatureSupport;MonoFond)", pad1)

	Dim hole1 As Hole
	Set hole1 = shapeFactory1.AddNewHoleFromPoint(-49.824203, -19.152611, 19.999998, reference1, 10.000000)

	hole1.ThreadingMode = catSmoothHoleThreading

	hole1.ThreadSide = catRightThreadSide

	part1.Update 

else 
	msgbox " The part is not updated : hole creation is not possible" 
end if 


End Sub
