Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

CATIA Code for Geometrical Sets

Status
Not open for further replies.

Prafulbari

Mechanical
Oct 24, 2013
5
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top