Alan Lowbands
Aerospace
- May 17, 2017
- 274
Hi Guys,
I'm trying to create a script to put a point in the centre of a hole then create a line from that relative to a planer face.
I have found some code that creates the first point and I've managed to alter it a little to send the point to a chosen geo set and also rename it.
I can't figure out how to get the rename to add a instance number like catia does when creating the points ie Point.1, Point.2 etc.
Does anyone know how to do this ?
After that I need to create a line.
I have found some commands from Automation V5 but how you put thim in to practice I don't know. I'm searching the web looking for a relative example.
Any help on either things would be really appreciated.
code below (whoever wrote that and shared, many thanks)
regards
Alan
---------------------------------------------------------------------------------------------------------------------------------------
Sub CATMain()
Set oDoc = CATIA.ActiveDocument
Set oPart = oDoc.Part
Dim reference1 'As Reference
Set oHSF = oPart.HybridShapeFactory
Dim InputObject(0)
InputObject(0) = "Edge"
Set oCentre = CATIA.ActiveDocument.Selection
Status = oCentre.SelectElement2(InputObject, "Select Circle", False)
Set oTemp = oCentre.Item(1)
Set oRef = oTemp.Reference
Set oPoint = oHSF.AddNewPointCenter(oRef)
'Set oHB = oPart.HybridBodies.Add() 'Will add a new Geometrical Set for each Point
Set oHB = oPart.HybridBodies.Item("Points") 'Sends to named Geo Set
oPoint.Name = "Hole Centre" &intIndex'+(oNo-1) ' Can't get this bit to rename in sequence
oPoint.Compute
oHB.AppendHybridShape oPoint
End Sub
' Found this in Automation V5
'Dim oSurface As Reference
'Set oSurface = LineNormal.Surface
'Dim oPoint As Reference
'Set oPoint = LineNormal.Point
'Dim oOrientation As long
'Set oOrientation = LineNormal.Orientation
'Dim oEnd As CATIALength
'Set oEnd = LineNormal.EndOffset
'Dim oStart As CATIALength
'Set oStart = LineNormal.BeginOffset
I'm trying to create a script to put a point in the centre of a hole then create a line from that relative to a planer face.
I have found some code that creates the first point and I've managed to alter it a little to send the point to a chosen geo set and also rename it.
I can't figure out how to get the rename to add a instance number like catia does when creating the points ie Point.1, Point.2 etc.
Does anyone know how to do this ?
After that I need to create a line.
I have found some commands from Automation V5 but how you put thim in to practice I don't know. I'm searching the web looking for a relative example.
Any help on either things would be really appreciated.
code below (whoever wrote that and shared, many thanks)
regards
Alan
---------------------------------------------------------------------------------------------------------------------------------------
Sub CATMain()
Set oDoc = CATIA.ActiveDocument
Set oPart = oDoc.Part
Dim reference1 'As Reference
Set oHSF = oPart.HybridShapeFactory
Dim InputObject(0)
InputObject(0) = "Edge"
Set oCentre = CATIA.ActiveDocument.Selection
Status = oCentre.SelectElement2(InputObject, "Select Circle", False)
Set oTemp = oCentre.Item(1)
Set oRef = oTemp.Reference
Set oPoint = oHSF.AddNewPointCenter(oRef)
'Set oHB = oPart.HybridBodies.Add() 'Will add a new Geometrical Set for each Point
Set oHB = oPart.HybridBodies.Item("Points") 'Sends to named Geo Set
oPoint.Name = "Hole Centre" &intIndex'+(oNo-1) ' Can't get this bit to rename in sequence
oPoint.Compute
oHB.AppendHybridShape oPoint
End Sub
' Found this in Automation V5
'Dim oSurface As Reference
'Set oSurface = LineNormal.Surface
'Dim oPoint As Reference
'Set oPoint = LineNormal.Point
'Dim oOrientation As long
'Set oOrientation = LineNormal.Orientation
'Dim oEnd As CATIALength
'Set oEnd = LineNormal.EndOffset
'Dim oStart As CATIALength
'Set oStart = LineNormal.BeginOffset