Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

Creating Axis Systems using a text file of excel file.

Status
Not open for further replies.

obbi

Mechanical
Joined
Aug 20, 2004
Messages
3
Location
SE
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
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top