Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Option Explicit
Sub CATMain()
Dim partDocument1 As PartDocument
Set partDocument1 = CATIA.ActiveDocument
Dim part1 As part
Set part1 = partDocument1.part
Dim hybridBodies1 As HybridBodies
Set hybridBodies1 = part1.HybridBodies
Dim hybridBody1 As HybridBody
Set hybridBody1 = hybridBodies1.item("Geometrical Set.1")
Dim varSelection As Variant
Set varSelection = partDocument1.Selection
Dim Sstatus
'selection of curve
ReDim sFilter(1)
'MsgBox "Select Curve"
sFilter(0) = "HybridShapeCurveExplicit"
sFilter(1) = "MonoDim"
Sstatus = varSelection.SelectElement2(sFilter, "Select curve", False)
Dim oCurve As Object
Set oCurve = varSelection.item(1).Value
Dim reference2 As Reference
Set reference2 = part1.CreateReferenceFromObject(oCurve)
varSelection.Clear
'selecting surface
ReDim sFilter(1)
'MsgBox "Select surface"
sFilter(0) = "HybridShape"
sFilter(1) = "MonoDim"
Sstatus = varSelection.SelectElement2(sFilter, "Select surface", False)
Dim osurface As Object
Set osurface = varSelection.item(1).Value
Dim surface As Reference
Set surface = part1.CreateReferenceFromObject(osurface)
varSelection.Clear
' Calculate curve length
Dim SpaWorkbench As SpaWorkbench
Dim theMeasurable As Measurable
Set SpaWorkbench = partDocument1.GetWorkbench("SPAWorkbench")
Set theMeasurable = SpaWorkbench.GetMeasurable(part1.CreateReferenceFromObject(oCurve))
part1.Update
'MsgBox CStr(theMeasurable.Length)
Dim b, C, D
b = theMeasurable.Length
'MsgBox "Curve length" & b
'Enter no of section
C = CInt(InputBox("Enter Required number of section"))
D = b / C
'Selection of Point
ReDim sFilter(0)
'MsgBox "Select Point"
sFilter(0) = "Point"
Sstatus = varSelection.SelectElement2(sFilter, "Select a point", False)
Dim opoint As Object
Set opoint = varSelection.item(1).Value
Dim reference1 As Reference
Set reference1 = part1.CreateReferenceFromObject(opoint)
varSelection.Clear
'select press direction
ReDim sFilter(1)
'MsgBox "Select cutting direction"
sFilter(0) = "HybridShapeCurveExplicit"
sFilter(1) = "MonoDim"
Sstatus = varSelection.SelectElement2(sFilter, "Select curve for direction", False)
Dim Pdirection As Object
Set Pdirection = varSelection.item(1).Value
Dim reference5 As Reference
Set reference5 = part1.CreateReferenceFromObject(Pdirection)
Dim direction As HybridShapeDirection
Set direction = part1.HybridShapeFactory.AddNewDirection(reference5)
'Creating geometries using loop
Dim i As Integer
For i = 1 To C
Dim hybridShapeFactory1 As HybridShapeFactory
Set hybridShapeFactory1 = part1.HybridShapeFactory
Dim hybridShapePointOnCurve1 As HybridShapePointOnCurve
Set hybridShapePointOnCurve1 = hybridShapeFactory1.AddNewPointOnCurveWithReferenceFromDistance(reference2, reference1, D * i, False)
hybridShapePointOnCurve1.DistanceType = 1
hybridBody1.AppendHybridShape hybridShapePointOnCurve1
part1.InWorkObject = hybridShapePointOnCurve1
' creating plane
Dim hybridShapePlaneNormal1 As HybridShapePlaneNormal
Set hybridShapePlaneNormal1 = hybridShapeFactory1.AddNewPlaneNormal(reference2, hybridShapePointOnCurve1)
'Intersection curve
Dim hybridShapeIntersection1 As HybridShapeIntersection
Set hybridShapeIntersection1 = hybridShapeFactory1.AddNewIntersection(hybridShapePlaneNormal1, surface)
hybridShapeIntersection1.PointType = 0
Dim hybridShapeNear1 As HybridShapeNear
Set hybridShapeNear1 = hybridShapeFactory1.AddNewNear(hybridShapeIntersection1, hybridShapePointOnCurve1)
hybridBody1.AppendHybridShape hybridShapeNear1
part1.UpdateObject hybridShapeNear1
'creating perpendicular line
Dim hybridShapeLinePtDir1 As HybridShapeLinePtDir
Set hybridShapeLinePtDir1 = hybridShapeFactory1.AddNewLinePtDir(hybridShapePointOnCurve1, direction, 0, 20, False)
' Dim hybridBody2 As HybridBody
' Set hybridBody2 = hybridBodies1.item("Geometrical Set.1")
hybridBody1.AppendHybridShape hybridShapeLinePtDir1
part1.UpdateObject hybridShapeLinePtDir1
Next i
'part1.Update
End Sub