Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Catia Export Point Co-ordinates 1

Status
Not open for further replies.

NaWin55

Mechanical
Mar 21, 2020
97
hello all.
i want to export X,Y & Z values of points to excel spreadsheet
i have created a macro where i can select X parameter but i am trying to export it to excel first column or any column, all the x values in one column
y & z
here is the macro
Option Explicit

Sub CATpoints()

Dim oDoc As Document
Set oDoc = CATIA.ActiveDocument

Dim rootPart As Part
Set rootPart = CATIA.ActiveDocument.Part

Dim partDoc As PartDocument
Set partDoc = CATIA.ActiveDocument

Dim oBodies As bodies
Set oBodies = rootPart.bodies

Dim oBody As Body
Set oBody = oBodies.Item(1)

Dim hyBShape As HybridShapes
Set hyBShape = oBody.HybridShapes

Dim oParam As Parameters
Set oParam = rootPart.Parameters
' MsgBox oParam.Count

Dim oSel As Selection
Set oSel = CATIA.ActiveDocument.Selection

Dim xPoint As Length
Set xPoint = oParam.Item("Part3\Geometrical Set.1\Point.1\X")

Dim yPoint As Length
Set yPoint = oParam.Item("Part3\Geometrical Set.1\Point.1\Y")

Dim zPoint As Length
Set zPoint = oParam.Item("Part3\Geometrical Set.1\Point.1\Z")

Dim oCollection As Collection
Set oCollection = New Collection

oSel.Search ("Name = 'X', all")
MsgBox oSel.Count
oCollection.Add oSel

Dim oExcel As Object
Dim oWorkbook As Workbook
Dim oSheet As Sheets

Set oExcel = CreateObject("Excel.Application")
oExcel.Visible = True
Set oWorkbook = oExcel.workBooks.Add
Set oSheet = oWorkbook.Sheets
oSheet.Item(1).Name = "Points"

End Sub

i dont know how to loop and print the value of x parameter to excel cells
please help me this is very impotent
Thanks.
 
Replies continue below

Recommended for you

@catiavbmacro
Get Coordinates and selectElement3 methods wont work for VBA
i tried GetCoordinates nothing worked

any other solution?
 
you should try to search "VBA CATIA RESTRICTED"

Eric N.
indocti discant et ament meminisse periti
 
Hello, I don't use VBA, so I don't know how it works, if you want graphic interface Visual Basic is always much better option.
 
@catiavbmacro
but i heard that many Catia automation users use VBA for design automation, i dont know how much CATSCRIPT is used in industry
Do you have any info on that, which one is used more in industry level?
 
VBA uses exactly the same API as CATScript to interact with CATIA, it is called Automation.

VBA has userforms, module-based structure and debugging, all of which combined makes it more developer-friendly. But it still doesn't even come close to a real language like VB6 and it's successor VB.NET. I'd say it's just better than Notepad.

CATScript is way faster than VBA and essentially is the same as VBScript with CATIA access. It's main limitation (just as with VBScript) is that it can't create window-based UI. Still can be debugged though, just not that easy.

"Industry level" relies on VB6 or VB.NET and CATScript, not VBA.
 
@Little Cthulhu, thank you for the answer
So learning VB.NET to automation is a good move right?
i am learning that right now
do you have any materials to learn vb.net catia automation
i know basics like importing library and creating UI and i also have knowledge in c#
 
So learning VB.NET to automation is a good move right?

Sure.

do you have any materials to learn vb.net catia automation

Check this thread.

There's nothing special in "CATIA in VB.NET" from VB.NET standpoint. It's no different from Excel, Word or other COM-server. So I stick with same advice as always - master CATIA first.

By the way I write code in C#
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor