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!

Macros

  • Thread starter Thread starter vinodhsha
  • Start date Start date
V

vinodhsha

Guest
Need some examples on use of macro in CATIA V5
smiley1.gif
 
dear all, please tell me how to create spline using coordinates in excel file in V5 using macros.


thanks
smiley2.gif
 
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.
 
V5Automation.chm

is in catia install folder
 
Hi GVI70000,
Thanks a lot for your help.

-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
 

Part and Inventory Search

Sponsor

Back
Top