Searching for lines
Searching for lines
(OP)
Good afternoon,
i have the following segment of code,
What i am trying to do, is to obtain the coordinates of each line, but while counting it gave me the number of lines, but when inserting in the vector lin, it is empty,
maybe i am missing something and i dont seeit, hope you can help me with this.
thank you
Set partDocument1 = CATIA.ActiveDocument
Set selection1 = partDocument1.Selection
selection1.Clear
Set part1 = partDocument1.Part
Set hybridBodies1 = part1.HybridBodies
Set hybridBody1 = hybridBodies1.Item("Geometrical Set.1")
selection1.Add hybridBody1
CATIA.ActiveDocument.Selection.Search("t:Line,sel")
lines = CATIA.ActiveDocument.Selection.count
ReDim lin(lines + 1)
For l = 1 To lines
Set lin(l) = CATIA.ActiveDocument.Selection.Item(l).Value
msgbox lin(l)
Next
for p = 0 to lin - 1
CATIA.ActiveDocument.Selection.Clear
CATIA.ActiveDocument.Selection.Add (lin(p))
Set oPartDoc = CATIA.ActiveDocument.Part
Set TheSPAWorkbench = CATIA.ActiveDocument.GetWorkbench("SPAWorkbench")
Set oSel = CATIA.ActiveDocument.Selection
On Error Resume Next
Set oRef = oSel.Item(1).Value
oRef.GetPointsOnCurve (coord)
xi = coord(0)
yi = coord(1)
zi = coord(2)
xf = coord(3)
yf = coord(4)
zf = coord(5)
msgbox xi
msgbox yi
msgbox zi
msgbox xf
msgbox yf
msgbox zf
Next
i have the following segment of code,
What i am trying to do, is to obtain the coordinates of each line, but while counting it gave me the number of lines, but when inserting in the vector lin, it is empty,
maybe i am missing something and i dont seeit, hope you can help me with this.
thank you
Set partDocument1 = CATIA.ActiveDocument
Set selection1 = partDocument1.Selection
selection1.Clear
Set part1 = partDocument1.Part
Set hybridBodies1 = part1.HybridBodies
Set hybridBody1 = hybridBodies1.Item("Geometrical Set.1")
selection1.Add hybridBody1
CATIA.ActiveDocument.Selection.Search("t:Line,sel")
lines = CATIA.ActiveDocument.Selection.count
ReDim lin(lines + 1)
For l = 1 To lines
Set lin(l) = CATIA.ActiveDocument.Selection.Item(l).Value
msgbox lin(l)
Next
for p = 0 to lin - 1
CATIA.ActiveDocument.Selection.Clear
CATIA.ActiveDocument.Selection.Add (lin(p))
Set oPartDoc = CATIA.ActiveDocument.Part
Set TheSPAWorkbench = CATIA.ActiveDocument.GetWorkbench("SPAWorkbench")
Set oSel = CATIA.ActiveDocument.Selection
On Error Resume Next
Set oRef = oSel.Item(1).Value
oRef.GetPointsOnCurve (coord)
xi = coord(0)
yi = coord(1)
zi = coord(2)
xf = coord(3)
yf = coord(4)
zf = coord(5)
msgbox xi
msgbox yi
msgbox zi
msgbox xf
msgbox yf
msgbox zf
Next





RE: Searching for lines
You are trying to get the coordinates of the starting and ending points of the lines?
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: Searching for lines
yes, and i already tried with the function Get.Coordinates and still is giving me nothing
RE: Searching for lines
indocti discant et ament meminisse periti
RE: Searching for lines
oRef.GetPointsOnCurve coord
not
oRef.GetPointsOnCurve (coord)
following the examples in FAQ
indocti discant et ament meminisse periti
RE: Searching for lines
hope you can help me with this.
'////////////Contar Lineas/////////////////
Set partDocument1 = CATIA.ActiveDocument
Set selection1 = partDocument1.Selection
selection1.Clear
Set part1 = partDocument1.Part
Set hybridBodies1 = part1.HybridBodies
Set hybridBody1 = hybridBodies1.Item("Geometrical Set.1")
selection1.Add hybridBody1
CATIA.ActiveDocument.Selection.Search("t:Line,sel")
lines = CATIA.ActiveDocument.Selection.count
Dim coord(6)
ReDim lin(lines)
For h = 0 To lines
Set lin(h) = CATIA.ActiveDocument.Selection.Item(h).Value
Next
for p = 0 to lines - 1
CATIA.ActiveDocument.Selection.Clear
CATIA.ActiveDocument.Selection.Add (lin(p + 1))
Set oPartDoc = CATIA.ActiveDocument.Part
Set TheSPAWorkbench = CATIA.ActiveDocument.GetWorkbench("SPAWorkbench")
Set oSel = CATIA.ActiveDocument.Selection
On Error Resume Next
Set oReff = oSel.Item(1).Value
oReff.GetPointsOnCurve coord
xi = coord(0)
yi = coord(1)
zi = coord(2)
xf = coord(3)
yf = coord(4)
zf = coord(5)
msgbox xi
msgbox yi
msgbox zi
msgbox xf
msgbox yf
msgbox zf
Next
RE: Searching for lines
CODE --> vbscript
Sub CATMain() Set partDocument1 = CATIA.ActiveDocument Set selection1 = partDocument1.Selection selection1.Clear Set part1 = partDocument1.Part Set hybridBodies1 = part1.HybridBodies Set hybridBody1 = hybridBodies1.Item("Geometrical Set.1") selection1.Add hybridBody1 CATIA.ActiveDocument.Selection.Search ("t:Line,sel") lines = CATIA.ActiveDocument.Selection.Count ReDim lin(lines + 1) For l = 1 To lines Set lin(l) = CATIA.ActiveDocument.Selection.Item(l).Value 'MsgBox lin(l) Next Dim p For p = 1 To lines CATIA.ActiveDocument.Selection.Clear CATIA.ActiveDocument.Selection.Add (lin(p)) Set oPartDoc = CATIA.ActiveDocument.Part Set TheSPAWorkbench = CATIA.ActiveDocument.GetWorkbench("SPAWorkbench") Set oSel = CATIA.ActiveDocument.Selection 'On Error Resume Next Set oRef = oSel.Item(1).Value Set Measurable1 = TheSPAWorkbench.GetMeasurable(oRef) ReDim coord(8) Measurable1.GetPointsOnCurve coord xi = coord(0) yi = coord(1) zi = coord(2) xm = coord(3) ym = coord(4) zm = coord(5) xf = coord(6) yf = coord(7) zf = coord(8) msgbox xi & vbCrLf & yi & vbCrLf & zi & vbCrLf & xf & vbCrLf & yf & vbCrLf & zf Next End SubThis works for me !!
RE: Searching for lines
RE: Searching for lines