Gilgamesh99
Automotive
Hi:
Working with the centerpoint extractor (Place Points in a tube macro post). I figured out how to get the edges and filter them (assigning them to an array). The issue now is that I cannot assign the filtered array to the selection in order to create the points. This is the code that Im using:
The code to create the points was provided by ferdo (CATIA portable script center V2.0):
Unfortunately this last portion of code only works with a selection and I dont find the way either to assign the array InputObject2 to the selection or replace the selection with the InputObject2.
At this point I tried everything to get this task accomplished but every effort of mine seems to be useless.
Working with the centerpoint extractor (Place Points in a tube macro post). I figured out how to get the edges and filter them (assigning them to an array). The issue now is that I cannot assign the filtered array to the selection in order to create the points. This is the code that Im using:
Code:
Sub CATMain()
Dim productDocument1
Set productDocument1 = CATIA.ActiveDocument
Dim documents1 As Documents
Set documents1 = CATIA.Documents
Dim partDocument1
Set partDocument1 = documents1.Item(1)
Dim part1 As Part
Set oPart = CATIA.ActiveDocument.Part
Dim reference1 As Reference
Set oHSF = oPart.HybridShapeFactory
'===========================================================
Dim objSel As Selection
Set objSel = CATIA.ActiveDocument.Selection
objSel.Search ("Type=Edge,Selection_BorderREdge")
objcount = objSel.Count
'MsgBox objcount
Dim i As Integer
Dim InputObject(99)
Dim InputObject2(99)
Dim j As Integer
'MsgBox objSel.Count
For i = 1 To objSel.Count
InputObject(i) = objSel.Item(i).Value.Name
If (InStrRev(InputObject(i), "Selection_REdge", -1) = 1) Then
'MsgBox "The current edge is a BorderREdge"
For j = 1 To 1
InputObject2(j) = InputObject(i)
MsgBox InputObject2(j)
Next j
End If
Next i
The code to create the points was provided by ferdo (CATIA portable script center V2.0):
VBA said:Dim oCentre
Set oCentre = CATIA.ActiveDocument.Selection
Dim j As Integer
For j = 1 To (objSel.Count)
Set otemp = oCentre.Item(j)
Set oRef = otemp.Reference
Set oPoint = oHSF.AddNewPointCenter(oRef)
'Set oHB = oPart.HybridBodies.Add()
oPoint.Compute
oHB.AppendHybridShape oPoint
Next j
'objSel.Clear
Unfortunately this last portion of code only works with a selection and I dont find the way either to assign the array InputObject2 to the selection or replace the selection with the InputObject2.
At this point I tried everything to get this task accomplished but every effort of mine seems to be useless.