×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Searching for lines

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

RE: Searching for lines

(OP)
thanks for answer,

yes, and i already tried with the function Get.Coordinates and still is giving me nothing

RE: Searching for lines

Quote (ONLINE DOC... again)

GetDirection
Retrieves the direction of the line.

Eric N.
indocti discant et ament meminisse periti

RE: Searching for lines

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

RE: Searching for lines

(OP)
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

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 Sub 

This works for me !!

RE: Searching for lines

(OP)
hi alexlozoya, thank you so much for your answer, it works perfect. i have to study more about this, thanks again

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources