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!

Macro to search text from Drawing Table & Ditto

Status
Not open for further replies.

sandy151

Computer
Sep 20, 2014
8
IN
I am looking for macro which can search text from Drawing Table & Drawing Dittos ( Instantiate 2D Component ).

I have macro to search whole Table & Ditto but unable to extract word from that.

My requirement is:
1)To extract only Text from Table & Dittos in drawing sheet.
2)After extracting word it should be disassemble ( Sentence should be disassembled into individual word ) .

Thanks in advance.
 
Replies continue below

Recommended for you

Don't want to be rude but you might have more chance to get help creating the script , than getting free work.

you said you can find drawing text but can't get word from it?

did you look the online doc? the answer is there in plain text

to split string with space you can use the split() function again in doc.

share you code or at least what you can from it and you'll find help



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

Thanks for the reply.

I have made below code to search all dittos (Instantiate 2D Component).

Sub CATMain()

Dim drawingDocument1 As DrawingDocument
Set drawingDocument1 = CATIA.ActiveDocument

Dim selection1 As Selection
Set selection1 = drawingDocument1.Selection

selection1.Search "CATDrwSearch.DrwDitto,all"

End Sub.


But i don't know how to extract word from this dittos.

I want to extract only words but this program select all item within dittos, like: Line , point, word , image...

Please help me to execute the program .

Thanks in advance.
 
Hello Ferdo,

I have searched but couldn't fount suitable for my requirement.

Below is latest script from me to search all text from drawing including Table , Ditto & Text.
Now only thing need to do is extracting of all text from Table & Ditto .

Sub CatMain()

Dim drawingDocument1 As DrawingDocument
Set drawingDocument1 = CATIA.ActiveDocument

Dim selection1 As Selection
Set selection1 = drawingDocument1.Selection

selection1.Search "((CATDrwSearch.DrwDitto + CATDrwSearch.DrwText + CATDrwSearch.DrwTable)),all"

End Sub


I have very basic knowledge of Macro so please help me in this regards .

Thanks..
 
Hi,

Please help me to correct the code, i have red marked to problem area :

Sub CATMain()

Dim drawingDocument1 As DrawingDocument
Set drawingDocument1 = CATIA.ActiveDocument

Dim selection1 As Selection
Set selection1 = drawingDocument1.Selection

selection1.Search "((CATDrwSearch.DrwDitto + CATDrwSearch.DrwText + CATDrwSearch.DrwTable)),all"

' Retrieve the modifiable text of the ditto
Dim oText As DrawingText
Set oText = o2DComponent.GetModifiableObject(1)

' Modify the modifiable text value
Dim ReturnValue As String
ReturnValue = InputBox("Enter a value", "", "New Value For Text")
oText.Text = ReturnValue

End Sub


Thanks....
 
you do selection1.Search but then you don't use it.

then you bring from nowhere the o2DComponent.

you could check in your view the Components collection. I always prefer to get the object from the data structure than using search or selection.

oDrawingDoc
|- Views
|- ActiveView
|- Components
|- item(1)
|- item(2)

Also you will find

oDrawingDoc
|- Views
|- ActiveView
|- Texts
|- item(1)
|- item(2)

This is the basic of CATIA data structure, please read your V5Automation.chm file

Eric N.
indocti discant et ament meminisse periti
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top