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!

help with catia search macro

Status
Not open for further replies.

noobcat

Aerospace
Nov 19, 2012
9
CA
hi, i am new in catia programing. I would really appreciate it if someone could help me get the program started. I would like to select a text in excel and it does something similar to ctrl H and search for the part number and zoom into the 2D drawing.
 
Replies continue below

Recommended for you

Hi,

As I can understand, you are trying to search in an EXCEL file something (ctrl F not H), if the part number exist then switch to CATIA drawing and zoom into that text, write?

So, your macro should be done in EXCEL (but not necessary) and "work" with CATIA.

Did you try something? Just for your information, in my opinion drafting workbench is not so friendly in automation....

Regards
Fernando

 
hi i was able to achieve it, but i do not know the vba code to reframe to a text

Option Explicit

Private Sub CommandButton1_Click()

ListBox1.AddItem ("2057510200-REF")
End Sub

Private Sub ListBox1_Click()


CATIA.DisplayFileAlerts = False
Dim oDrwDocument As Document
Dim oDrwviews As DrawingViews
Dim drwSelect As Selection
Dim iViews As Long
Set oDrwDocument = CATIA.ActiveDocument

' Retrieve the drawing document's view collection

Set oDrwviews = oDrwDocument.Sheets.Item(1).Views

'For each view search text
Set drwSelect = CATIA.ActiveDocument.Selection

For iViews = 1 To oDrwviews.Count

'Scan all the Texts of the Views
Dim itxt As Integer

For itxt = 1 To oDrwviews.Item(iViews).Texts.Count
Dim getPart As String
getPart = ("*" & oDrwviews.Item(iViews).Texts.Item(itxt).Text & "*")

If InStr(getPart, ListBox1.Text) Then

drwSelect.Add oDrwviews.Item(iViews).Texts.Item(itxt)
CATIA.ActiveWindow.Reframe
Exit Sub

End If

Next

Next






'If CurrentView.Name <> "Background View" Then

'TextFont = odrwview.Item(i).Texts.Item(numtxt).GetFontSize(0, 0)

'If TextFont > 7 Then

'Change the color of the text in RED


'drwselect.Add odrwview.Item(i).Texts.Item(numtxt)

'drwselect.VisProperties.SetRealColor 255, 0, 0, 0

'End If

'End If



'CATIA.ActiveWindow.ActiveViewer.Reframe

'MsgBox "Text highlighted in RED has text height > 7 mm", vbInformation


End Sub
 
yes i did, it didnt zoom into my text, because it only calls on reframe views. if you can help me determine what calls Ctrl H and ultilize the reframe from there, that would help alot.
 
I don't think is possible in vba (I didn't search for this in docs, maybe someone else can give more ideas, maybe use SendKeys in the new pop-up window ?).

Maybe CATIA.StartCommand "Magnifier" if you want to have just a visual confirmation ?

Regards
Fernando

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top