Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Searching for lines 1

Status
Not open for further replies.

theing

New member
Mar 5, 2014
18
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
 
Replies continue below

Recommended for you

thanks for answer,

yes, and i already tried with the function Get.Coordinates and still is giving me nothing
 
ONLINE DOC... again said:
GetDirection
Retrieves the direction of the line.

Eric N.
indocti discant et ament meminisse periti
 
but if you want the points you should try:

oRef.GetPointsOnCurve coord
not
oRef.GetPointsOnCurve (coord)

following the examples in FAQ

Eric N.
indocti discant et ament meminisse periti
 
hi itsmyjob, i have the following code, becouse i found some mistakes, but it just select the line, but it does not give me the coordinates, i dont know if a retriving the name by the correct way,
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
 
Code:
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 Sub

This works for me !!
 
hi alexlozoya, thank you so much for your answer, it works perfect. i have to study more about this, thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor