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!

text in drawing to part 1

Status
Not open for further replies.

JeniaL

Mechanical
Jun 3, 2014
547
IL
i have a macro that inserts text from a drawing to part.Thanx Ferdo for that macro it's from your portable script.
what i want is to insert text in a active part.this macro opens a new part and inserts text in there.
macro attached.
any help will be appreciated.
 
 http://files.engineering.com/getfile.aspx?folder=8c5518da-e790-4b76-a88e-e463218b4278&file=DRAWING_TEXT_TO_SKETCH.zip
Replies continue below

Recommended for you

With the dwg file active in CATIA and an already opened CATPart (the code bellow is a quick and dirty mix of a recorded macro and some other old code).

Code:
Language="VBSCRIPT"

Sub CATMain()

Dim drawingDocument1 As Document
Set drawingDocument1 = CATIA.ActiveDocument

Dim selection1 As Selection
Set selection1 = drawingDocument1.Selection

selection1.Clear 

Dim drawingSheets1 As DrawingSheets
Set drawingSheets1 = drawingDocument1.Sheets

Dim drawingSheet1 As DrawingSheet
Set drawingSheet1 = drawingSheets1.Item("Model")

Set drawingDocument1 = CATIA.ActiveDocument
Set selection1 = drawingDocument1.Selection

selection1.Search "Name=*Main' 'View*,all"
selection1.Copy 

'''''''''''''''''''''''''
Rem---------------------------
Rem User selection of the CATIA window
Rem--------------------------

Dim Windows1 As Windows
Dim SpecsAndGeomWindow1 As Window
Dim sArray As Array

Set Windows1 = Catia.Windows
DUMMY = ""
ii = 1
For i = 1 To Windows1.count
	WindowName = Windows1.Item( i ).Name

        	DUMMY = DUMMY & ii & ".)  " & WindowName & Chrw( 10 )
        	ii = ii + 1

Next

DUMMY = "Enter your Number, for example 1 or 2 " & Chrw( 10 )  & Chrw( 10 )& DUMMY & Chrw( 10 ) & Chrw( 10 ) 
USERCHOICE = InputBox( DUMMY, "Enter Number of Window which will be activated:" )

If USERCHOICE = "" Then
Exit Sub
End If

If IsNumeric( USERCHOICE ) Then
        iSelect = CInt(USERCHOICE)       
        WindowName = Windows1.Item(iSelect).Name      
        Windows1.Item(iSelect).Activate
End If
''''''''''''''''''''''''''
Set specsAndGeomWindow1 = CATIA.ActiveWindow

Dim viewer3D1 As Viewer
Set viewer3D1 = specsAndGeomWindow1.ActiveViewer

Dim viewpoint3D1 As Viewpoint3D
Set viewpoint3D1 = viewer3D1.Viewpoint3D

Dim partDocument1 As Document
Set partDocument1 = CATIA.ActiveDocument

Dim selection2 As Selection
Set selection2 = partDocument1.Selection

selection2.Clear 

Dim part1 As Part
Set part1 = partDocument1.Part

Dim bodies1 As Bodies
Set bodies1 = part1.Bodies

Dim body1 As Body
Set body1 = bodies1.Item("PartBody")

selection2.Add body1

selection2.Paste 

End Sub

Regards
Fernando

 
thanx. i did some changes to macro and it works very well. i liked choosing windows where to put dxf/dwg. is there any way to set catia to export/import dxf files with mostly arcs and lines?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top