Results 1 to 2 of 2

Thread: excel to catia

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2004
    Location
    NEW YORK CITY
    Posts
    2

    excel to catia

    Hi All,
    I recorded this macro from a CAD program, called CATIA. What it does is creates a point and a sphere. what i want it to do is to loop for as many rows in an an excel spreadsheet. the spreadsheet is where i get my x,y & z values for the point.
    Does anyone know how to solve this problem. Thanks.
    Language="VBSCRIPT"

    Sub CATMain()

    Set documents1 = CATIA.Documents

    Set partDocument1 = documents1.Add("Part")

    Set part1 = partDocument1.Part

    Set hybridBodies1 = part1.HybridBodies

    Set hybridBody1 = hybridBodies1.Add()

    Set hybridShapeFactory1 = part1.HybridShapeFactory

    Set hybridShapePointCoord1 = hybridShapeFactory1.AddNewPointCoord(0.000000, 0.000000, 0.000000)

    hybridBody1.AppendHybridShape hybridShapePointCoord1

    part1.InWorkObject = hybridShapePointCoord1

    part1.Update

    Set reference1 = part1.CreateReferenceFromObject(hybridShapePointCoord1)

    Set hybridShapeSphere1 = hybridShapeFactory1.AddNewSphere(reference1, Nothing, 76.200000, -45.000000, 45.000000, 0.000000, 180.000000)

    hybridShapeSphere1.Limitation = 1

    hybridBody1.AppendHybridShape hybridShapeSphere1

    part1.InWorkObject = hybridShapeSphere1

    part1.Update

    End Sub

  2. #2
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    VB Code:
    1. Dim intRowCounter 'As Integer
    2.    
    3. For intRowCounter = 1 To UsedRange.Rows.Count
    4.    
    5. Next intRowCounter

    I've taken off the variable data type there as you put you're using vbscript. In Excel, there is a UsedRange object which you can reference above to find the amount of used rows in a worksheet and start a loop from.

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width