i want to construct lines normal to a face using the centroid as a reference, but, some how one of the two references for addnewlinenormal is not working, it says it requires an object. what am i doing wrong?
For i = 1 To X
Set objsel = CATIA.ActiveDocument.Selection
objsel.Clear
objsel.Search "Type=Topology.Face,all"
X = objsel.Count2
Set partDocument1 = CATIA.ActiveDocument
Set part1 = partDocument1.Part
Set Selection = partDocument1.Selection
Set reference1 = Selection.Item(i).Reference
Set spabench = partDocument1.GetWorkbench("SPAWorkbench")
Set mymeas = spabench.GetMeasurable(reference1)
myans = mymeas.Area
data_file.WriteLine ("Cara #" & i)
data_file.WriteLine (myans)
'****************Centroides
Set centroide = spabench.GetMeasurable(reference1)
Dim mycoord(2)
centroide.GetCOG mycoord
xc = mycoord(0)
yc = mycoord(1)
zc = mycoord(2)
'***************Creacion de los puntos de centroides
Dim punto As HybridShapeFactory
Set punto = part1.HybridShapeFactory
Dim coord As HybridShapePointCoord
Set coord = punto.AddNewPointCoord(xc, yc, zc) 'Variables
Dim hybridBodies1 As HybridBodies
Set hybridBodies1 = part1.HybridBodies
Dim hybridBody1 As HybridBody
Set hybridBody1 = hybridBodies1.Item("Geometrical Set.1")
hybridBody1.AppendHybridShape coord
Dim reference2 As Reference
Set reference2 = part1.CreateReferenceFromGeometry(coord)
data_file.WriteLine "Coordenadas del centroide"
data_file.WriteLine ("X: " & mycoord(0))
data_file.WriteLine ("Y: " & mycoord(1))
data_file.WriteLine ("Z: " & mycoord(2))
part1.Update
'*************************creacion de la linea normal
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
Dim solid1 As Solid
Set solid1 = shapes1.Item("PartBody")
Dim hybridShapeLineNormal1 As HybridShapeLineNormal
Set hybridShapeLineNormal1 = hybridShapeFactory1.AddNewLineNormal(reference1, reference2, 0#, 20#, False)
hybridBody1.AppendHybridShape hybridShapeLineNormal1
part1.InWorkObject = hybridShapeLineNormal1
part1.Update
thanks in advance
For i = 1 To X
Set objsel = CATIA.ActiveDocument.Selection
objsel.Clear
objsel.Search "Type=Topology.Face,all"
X = objsel.Count2
Set partDocument1 = CATIA.ActiveDocument
Set part1 = partDocument1.Part
Set Selection = partDocument1.Selection
Set reference1 = Selection.Item(i).Reference
Set spabench = partDocument1.GetWorkbench("SPAWorkbench")
Set mymeas = spabench.GetMeasurable(reference1)
myans = mymeas.Area
data_file.WriteLine ("Cara #" & i)
data_file.WriteLine (myans)
'****************Centroides
Set centroide = spabench.GetMeasurable(reference1)
Dim mycoord(2)
centroide.GetCOG mycoord
xc = mycoord(0)
yc = mycoord(1)
zc = mycoord(2)
'***************Creacion de los puntos de centroides
Dim punto As HybridShapeFactory
Set punto = part1.HybridShapeFactory
Dim coord As HybridShapePointCoord
Set coord = punto.AddNewPointCoord(xc, yc, zc) 'Variables
Dim hybridBodies1 As HybridBodies
Set hybridBodies1 = part1.HybridBodies
Dim hybridBody1 As HybridBody
Set hybridBody1 = hybridBodies1.Item("Geometrical Set.1")
hybridBody1.AppendHybridShape coord
Dim reference2 As Reference
Set reference2 = part1.CreateReferenceFromGeometry(coord)
data_file.WriteLine "Coordenadas del centroide"
data_file.WriteLine ("X: " & mycoord(0))
data_file.WriteLine ("Y: " & mycoord(1))
data_file.WriteLine ("Z: " & mycoord(2))
part1.Update
'*************************creacion de la linea normal
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
Dim solid1 As Solid
Set solid1 = shapes1.Item("PartBody")
Dim hybridShapeLineNormal1 As HybridShapeLineNormal
Set hybridShapeLineNormal1 = hybridShapeFactory1.AddNewLineNormal(reference1, reference2, 0#, 20#, False)
hybridBody1.AppendHybridShape hybridShapeLineNormal1
part1.InWorkObject = hybridShapeLineNormal1
part1.Update
thanks in advance