×
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

CATIA Code for Geometrical Sets

CATIA Code for Geometrical Sets

CATIA Code for Geometrical Sets

(OP)
Here is the macro I am trying to create
I have drawn the geometry in geometrical sets and also defined parameters and formulas to derive that geometry. Now I have an excel input file with 302 data points which I would like use to derive those parameters. So for one set of data point I will have one geometrical set and so on. then I will have set of points in space and then I would like them to connect (line or smooth curve) through VB. Let me know if it is still not clear, I would love to explain more.

I am trying to create the for loop in VB but it is not at all working, can anyone help me getting the right code. Please....Here is my code:

Sub CATMain()
Set partDocument1 = CATIA.ActiveDocument
Set part1 = partDocument1.Part

Set objExcel = CreateObject("Excel.Application")
Set workbook = objExcel.Workbooks.Open("C:\data\Projects\Track_CATIA_coe\track pack\Interpolation NEW\Result\interpolation20130701115228.xls")
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'UPDATE ABOVE ADDRESS AND FILE NAME TO LOCATE AND EXECUTE CORRECT WAY POINT XLS
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
For loopcount = 2 To 3
Dim hybridBodies1 As HybridBodies
Set hybridBodies1 = part1.HybridBodies
Dim hybridBody1 As HybridBody
Set hybridBody1 = hybridBodies1.Item(loopcount - 1)
Dim hybridBody2 As HybridBody
Dim selection1 As Selection
Set selection1 = partDocument1.Selection
selection1.Add hybridBody1
selection1.Copy
selection1.Add hybridBody1 ' Add the Set where the copied data will be pasted in the selection
selection1.Paste
'Set hybridBody2 = selection1.Item(1)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'UPDATE NUMBER OF ITERATIONS EQUAL TO NUMBER OF TOTAL ROWS IN THE WAY POINT XLS
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Z = objExcel.Cells(loopcount, 2).Value
X = objExcel.Cells(loopcount, 3).Value
A = objExcel.Cells(loopcount, 4).Value
C = objExcel.Cells(loopcount, 5).Value
Set Parameters1 = part1.Parameters
Set Length1 = Parameters1.Item("X")
Length1.Value = X
Set parameters2 = part1.Parameters
Set Length2 = parameters2.Item("Z")
Length2.Value = Z
Set parameters3 = part1.Parameters
Set angle1 = parameters3.Item("A")
angle1.Value = A
Set parameters4 = part1.Parameters
Set angle2 = parameters4.Item("C")
angle2.Value = C
part1.Update
Dim product1 As Product
Set product1 = partDocument1.GetItem("Part" & loopcount)
aa = loopcount + 1
product1.PartNumber = "Part" & aa
part1.Update
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'UPDATE ABOVE ADDRESS TO LOCATE WHERE THE RESULT CAD FILES SHOULD GO...
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Next
CATIA.ActiveDocument.SaveAs "C:\data\Projects\Track_CATIA_coe_Amit\track pack\RESULT 28 MM\" & loopcount & "section.catpart"

End Sub

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