Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Export Text ( Placards) from Catia to Excel

Status
Not open for further replies.

vinodnx7

Industrial
Jan 21, 2010
19
0
0
CA
I am looking Micro to export all the text from Catia to Excel. I am attaching draft image for your reference, I want export the text in Excel to validate the spelling mistake for bilingual placard. created induvial placard in details view refer Placards 1. an
Placards_hyct2n.png
y help will much appreciated.
 
Replies continue below

Recommended for you

So you're trying to make a VB script to get all texts in drawing view to be copied to an excel workbook? Nice project.

Where is your problem?

Eric N.
indocti discant et ament meminisse periti
 
Hello Eric,
Yes the what I want, I want to copy each statement in excel by micro. which makes easy to compare the statements between two excel files (Native excel in French or any other language and Catia exported excel). sometime i seen some typo error while doing copay pate or, missing note. but if i use micro there will not a problem.
I am not good in VB . thus I'm searching for some help in this community.
 
Hello Eric,

try this but not working


Sub Export_Drawing_Texts()

Path = "D:\Book1.xlsx"


Set objExcel = CreateObject("Excel.Application")
Set workbook = objExcel.Workbooks.Open(Path)
workbook.Application.Visible = True
workbook.Parent.Windows(1).Visible = True


objExcel.Cells(1, 1).Value = "Text Name"
objExcel.Cells(1, 2).Value = "Text Value"

Dim oDrawing As DrawingDocument
Set oDrawing = CATIA.ActiveDocument


Dim oSheets As DrawingSheets
Set oSheets = oDrawing.Sheets

For A = 1 To oSheets.Count

Dim oSheet As DrawingSheet
Set oSheet = oSheets.Item(A)

Dim oView As DrawingView
Set oView = oSheet.Views.Item(1)
oView.Activate

Dim oText As DrawingTexts
Set oText = oView.Texts

For i = 2 To oText.Count
Set ThisDrawingText = oText.Item(i)
objExcel.Cells(i, 1).Value = ThisDrawingText.Name
objExcel.Cells(i, 2).Value = ThisDrawingText.Text

Next i

Next A
End Sub
 
this is not really needed:

Code:
oView.Activate

problem with the loop :

Code:
For i = 2 To oText.Count
Set ThisDrawingText = oText.Item(i)
objExcel.Cells(i, 1).Value = ThisDrawingText.Name
objExcel.Cells(i, 2).Value = ThisDrawingText.Text

Next i

the first text this loop will find is oText.item(2)
you will miss few texts in your drawing....

maybe the following will work better:

Code:
For i = 1 To oText.Count
Set ThisDrawingText = oText.Item(i)
objExcel.Cells(i+1, 1).Value = ThisDrawingText.Name
objExcel.Cells(i+1, 2).Value = ThisDrawingText.Text

Next i

What is the problem / error you have ?


Eric N.
indocti discant et ament meminisse periti
 
ah... ok i have the feeling the excel counter need to keep going, no matter which sheet, view and text...

replace

Code:
objExcel.Cells(1, 1).Value = "Text Name"
objExcel.Cells(1, 2).Value = "Text Value"

with

Code:
objExcel.Cells(1, 1).Value = "Text Name"
objExcel.Cells(1, 2).Value = "Text Value"

set myXLCell = objExcel.Range ("B1")


and in your loop replace

Code:
objExcel.Cells(i, 1).Value = ThisDrawingText.Name
objExcel.Cells(i, 2).Value = ThisDrawingText.Text

with

Code:
objExcel.myXLCell.Value = ThisDrawingText.Name
objExcel.myXLCell.Offset(1).Value = ThisDrawingText.Text

set myXLCell = myXLCell.Offset(0,1)



Eric N.
indocti discant et ament meminisse periti
 
sorry about that

replace

objExcel.myXLCell.Value = ThisDrawingText.Name
objExcel.myXLCell.Offset(1).Value = ThisDrawingText.Text

set myXLCell = myXLCell.Offset(0,1)

with

myXLCell.Value = ThisDrawingText.Name
myXLCell.Offset(0,1).Value = ThisDrawingText.Text

set myXLCell = myXLCell.Offset(1)

Eric N.
indocti discant et ament meminisse periti
 
ok maybe something like this

drtext_to_xl_bk3f71.png


Code:
[COLOR=#AD7FA8][i]Dim myDr As DrawingRoot
Set myDr = CATIA.ActiveEditor.ActiveObject
[b]I am on 3DEXPERIENCE so you have a adapt this[/b][/i][/color]

Dim mySheet As DrawingSheet
Dim myView As DrawingView
Dim myText As DrawingText

For Each mySheet In myDr.Sheets

    For Each myView In mySheet.Views
    
        If myView.Texts.Count > 0 Then
        
            For Each myText In myView.Texts
    
                
                myRange.Value = myView.Name
                myRange.Offset(0, 1).Value = myText.Name
                myRange.Offset(0, 2).Value = myText.Text
                
                Set myRange = myRange.Offset(1)
                
            Next
        End If
        
    Next

Next


Eric N.
indocti discant et ament meminisse periti
 
I am using 3DEXPERIENCE I have the feeling you're not.

in 3DX I get the active drawing with

Code:
Set myDr = CATIA.ActiveEditor.ActiveObject

in CATIA V5 you do

Code:
Dim myDr As DrawingDocument
Set myDr = CATIA.ActiveDocument

Eric N.
indocti discant et ament meminisse periti
 
also do not forget to include the EXCEL definition section in your code...

Code:
Set objExcel = CreateObject("Excel.Application")
Set workbook = objExcel.Workbooks.Open(Path)
workbook.Application.Visible = True
workbook.Parent.Windows(1).Visible = True


objExcel.Cells(1, 1).Value = "Text Name"
objExcel.Cells(1, 2).Value = "Text Value"

set myRange= objExcel.Range ("B1")

Eric N.
indocti discant et ament meminisse periti
 
Hello Eric,

Thanks is working but, still i am missing some placard text and also look like micro stop working with some issue please check

what I am getting when i run the micro

Capture_-3_ctgru0.png


and error

Capture_-4_vu8upx.png


Thanks once again for your prompt support
 
well if you don't need the view name in your output.. just remove this line!

Code:
myRange.Value = myView.Name

Eric N.
indocti discant et ament meminisse periti
 
maybe you could set myRange to A2 (instead of B1) so title and data will be aligned

Eric N.
indocti discant et ament meminisse periti
 
Hello Eric,

you are the best, you made my date. Micro is working like a butter

thanks a looooooooooooot for your help

have a nice weekend

Regards
 
Status
Not open for further replies.
Back
Top