Continue to Site

Macros

Sub CATMain()
Dim xlTmp As Object
Dim xlSheet As Object
Set xlTmp = CreateObject("Excel.Application")
Dim strFileName As String
Dim xi, xj As Integer
strFileName = "F:\Schnecke.xls"
xlTmp.Workbooks.Add strFileName
'xlTmp.ActiveWorkbook.Open Filename:=strFileName
xlTmp.Visible = True
Set xlSheet = xlTmp.ActiveSheet
Dim partDocument1 As PartDocument
Set partDocument1 = CATIA.ActiveDocument

Dim part1 As Part
Set part1 = partDocument1.Part

Dim hybridShapeFactory1 As HybridShapeFactory
Set hybridShapeFactory1 = part1.HybridShapeFactory

Dim hybridShapePointCoord1 As HybridShapePointCoord
Dim axisSystems1 As AxisSystems
Dim axisSystem1 As AxisSystem
Dim reference1 As Reference
Dim hybridBodies1 As HybridBodies
Dim hybridBody1 As HybridBody
Dim i As Integer
Dim x As Double
Dim y As Double
For i = 5 To 77
x = xlSheet.cells(i, 3)
y = xlSheet.cells(i, 4)

Set hybridShapePointCoord1 = hybridShapeFactory1.AddNewPointCoord(x, y, 0#)
Set axisSystems1 = part1.AxisSystems
Set axisSystem1 = axisSystems1.Item("Absolute Axis System")
Set reference1 = part1.CreateReferenceFromObject(axisSystem1)
hybridShapePointCoord1.RefAxisSystem = reference1
Set hybridBodies1 = part1.HybridBodies
Set hybridBody1 = hybridBodies1.Item("GS1")
hybridBody1.AppendHybridShape hybridShapePointCoord1
part1.InWorkObject = hybridShapePointCoord1
part1.Update
Next i
End Sub


u can make the spline by hand at the end.
GS1 is the name of the geometrical set of the points.
PS: Change the columns number from the code above according to your needs.
</pre>

Edited by: gvi70000
 
Hi,
Could you please let me know if there are any books/notes available for catia VB script.

I want to learn script programming for catia v5.

Your help is appreciated in this.

Thanks
Bala.
 
HELLO,


MACRO STOPS JUST IN THE 2ND LINE:(


THERE IS ALSO A CHAPTER IN ONLINE DOC ABOUT THIS: "Creating Elements From An External File" - YOU CAN LOOK FOR THIS USING SEARCH.


REGARDS
 

Sponsor

Back
Top