×
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

Creating Axis Systems using a text file of excel file.

Creating Axis Systems using a text file of excel file.

Creating Axis Systems using a text file of excel file.

(OP)
I have a script creating points by using an excel file.
I would like to create axis systems in the same manner.
The format should be as in the below example
' A B C D E F G
' 1 Name X Y Z rX rY rZ
' 2 Axis1 123,321 123,321 123,321 45 90 120
' 3 Axis2 456,654 456,654 456,654 45 90 120
' 4 Axis3 789,987 789,987 789,987 45 90 120

Can anyone help me creating a script?


Reards
RobertW


Sub CATMain()
'''''''''''''''''''''''''''''''''''''
' ÅF Robotic Engineering Olofström '
'''''''''''''''''''''''''''''''''''''
' A B C D
' 1 Name X Y Z
' 2 Point1 123,321 123,321 123,321
' 3 Point2 456,654 456,654 456,654
' 4 Point3 789,987 789,987 789,987
' 5 ...
'''''''''''''''''''''''''''''''''''''''''
'
' Start Catia, Open a new CATPart, give it a good name
' Tools-> Macro-> Macros (Alt+F8)
' Select this script and then Run. When prompted select your .xls-file formatted in the above manner.
'
'''''''''''''''''''''''''''''''''''''''''
YourFile = CATIA.FileSelectionBox("Select file!", "*.xls", CatFileSelectionModeOpen)


Dim EXCEL As Object
Set EXCEL = CreateObject("Excel.Application")
EXCEL.Workbooks.Open YourFile

Dim X As Double
Dim Y As Double
Dim Z As Double

Dim partDocument1 As PartDocument
Set partDocument1 = CATIA.ActiveDocument

Dim part1 As Part
Set part1 = partDocument1.Part

Dim hybridBodies1 As HybridBodies
Set hybridBodies1 = part1.HybridBodies

Dim hybridBody1 As HybridBody
Set hybridBody1 = hybridBodies1.Add()

Dim hybridShapeFactory1 As HybridShapeFactory
Set hybridShapeFactory1 = part1.HybridShapeFactory

Dim bNotFound as boolean
Dim i As Integer
i = 2

While Not bNotFound

PointName = EXCEL.cells(i, 1).Value
X = EXCEL.cells(i, 2).Value
Y = EXCEL.cells(i, 3).Value
Z = EXCEL.cells(i, 4).Value
if (x+y+z) = 0.0 AND PointName = "" then
bNotFound = true
else
if not((x+y+z) = 0.0) then
Dim hybridShapePointCoord1 As HybridShapePointCoord
Set hybridShapePointCoord1 = hybridShapeFactory1.AddNewPointCoord(X, Y, Z)

hybridBody1.AppendHybridShape hybridShapePointCoord1

part1.InWorkObject = hybridShapePointCoord1
hybridShapePointCoord1.Name = PointName
part1.Update
end if
end if
i = i+1
wend

EXCEL.Application.Quit

End Sub

RE: Creating Axis Systems using a text file of excel file.

do you speak german? I don't.

but if you do you will tell us if this is what you're looking for:

check this: ww3.cad.de/foren/ubb/Foruum137/HTML/005591.shtml#000007 remove one u from foruum ... I had to add one for the link to show properly



Eric N.
indocti discant et ament meminisse periti

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