×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Catia drawing. macro for simple geometry

Catia drawing. macro for simple geometry

Catia drawing. macro for simple geometry

(OP)
trying to create simple geometry like line or circle in drawing environment but nothing happens.
i'm copying commands from a title block macro but nothing happens.
can anyone share a code for creating line and a circle?

thanks in advance.

RE: Catia drawing. macro for simple geometry

(OP)
sure. recording does'n work for me in drawing environment

RE: Catia drawing. macro for simple geometry

I've remembered that I post in the past an example for a Spanish forum...there are just few commands to start creating a title block, if you comment from
'Set myText.... As DrawingText - adding texts line to 'Declarations line, you can see just creation of the lines in background view.

CODE --> CATScript

' ======================================================
' Purpose: Macro will activate the backgroud view in an active CATIA drawing (A4 sheet) and will draw a title block
' Usage:   1 - A CATDrawing must be active
'          2 - Run macro 
' Author: ferdo (Disclaimer: You use this code at your own risk) 
' ======================================================
Language="VBSCRIPT"

' made as example by ferdo for auxcad.com

Sub CATMain()

Dim CATIA As Object
Set CATIA = GetObject(, "CATIA.Application")

Dim MyDrawingDoc As DrawingDocument
Set MyDrawingDoc = CATIA.ActiveDocument

Dim MyDrawingSheets As DrawingSheets
Set MyDrawingSheets = MyDrawingDoc.Sheets

Dim MyDrawingSheet As DrawingSheet
Set MyDrawingSheet = MyDrawingSheets.ActiveSheet

Dim MyDrawingViews As DrawingViews
Set MyDrawingViews = MyDrawingSheet.Views

Dim drwviews As DrawingViews  'make background view active
Set drwviews = MyDrawingSheet.Views
drwviews.Item("Background View").Activate

'Set myText.... As DrawingText - adding texts
Set myText = MyDrawingViews.ActiveView.Texts.Add ("Dibujado", 22, 38) 'coordinates x=22, y=38 of left bottom corner of the text location
Set myText1 = MyDrawingViews.ActiveView.Texts.Add ("Corregido", 22, 31)
Set myText2 = MyDrawingViews.ActiveView.Texts.Add ("Fecha", 57, 46)
Set myText3 = MyDrawingViews.ActiveView.Texts.Add ("DD-mm-08", 57, 38)
Set myText4 = MyDrawingViews.ActiveView.Texts.Add ("DD-mm-08", 57, 31)
Set myText5 = MyDrawingViews.ActiveView.Texts.Add ("Nombre", 87, 46)
Set myText6 = MyDrawingViews.ActiveView.Texts.Add ("Jefatura", 87, 38)
Set myText7 = MyDrawingViews.ActiveView.Texts.Add ("Delineante", 87, 31)
Set myText8 = MyDrawingViews.ActiveView.Texts.Add ("Empresa S.A.", 159, 40)
Set myText9 = MyDrawingViews.ActiveView.Texts.Add ("C/laredo 8, 2B", 159, 32)

Set myText13 = MyDrawingViews.ActiveView.Texts.Add ("Escalas:", 22, 23)
Set myText14 = MyDrawingViews.ActiveView.Texts.Add ("1/X", 22, 17)
Set myText15 = MyDrawingViews.ActiveView.Texts.Add ("1/X", 22, 11)
Set myText16 = MyDrawingViews.ActiveView.Texts.Add ("Firma", 128, 38)

Dim iFortSize1 As Double 'font text size 
iFontSize1 = 3.500
myText1.SetFontSize 0, 0, 3.500  'iFontSize

'next lines with a different size for fonts - 2.5
Set myText10 = MyDrawingViews.ActiveView.Texts.Add ("Sustituye a: xxx-08", 155, 22)
Set myText11 = MyDrawingViews.ActiveView.Texts.Add ("Sustituido por: xxx-08", 155, 12)

Dim iFortSize10 As Double
iFontSize10 = 2.500
myText10.SetFontSize 0, 0, 2.500  'iFontSize

Dim iFortSize11 As Double
iFontSize11 = 2.500
myText11.SetFontSize 0, 0, 2.500  'iFontSize

'next lines with a different size for fonts - 5
Set myText12 = MyDrawingViews.ActiveView.Texts.Add ("plano No xxx-08", 70, 18)

Dim iFortSize12 As Double
iFontSize12 = 5.00
myText12.SetFontSize 0, 0, 5.00  'iFontSize

'Declarations

Dim DrwDocument   As DrawingDocument
Dim DrwSheets     As DrawingSheets
Dim DrwSheet      As DrawingSheet
Dim DrwView       As DrawingView
Dim DrwTexts      As DrawingTexts
Dim Text          As DrawingText
Dim Fact          As Factory2D
Dim Point         As Point2D
Dim Line          As Line2D
Dim Cicle         As Circle2D
Dim Selection     As Selection
Dim GeomElems     As GeometricElements


  Set DrwDocument = CATIA.ActiveDocument
  Set DrwSheets   = DrwDocument.Sheets
  Set Selection   = DrwDocument.Selection
  Set DrwSheet    = DrwSheets.ActiveSheet
  Set DrwView     = DrwSheet.Views.ActiveView
  Set DrwTexts    = DrwView.Texts
  Set Fact        = DrwView.Factory2D
  Set GeomElems   = DrwView.GeometricElements


'draw frame bottom line
    Set Line1 = Fact.CreateLine(20, 5, 205, 5) 'these are the coordinates of the starting point x=20, y=5 of the line and end point of the line x=205, y=5
    Line1.Name = "Line1"
    CATIA.ActiveDocument.Selection.VisProperties.SetRealWidth 3,1
    CATIA.ActiveDocument.Selection.Clear
    
'draw frame upper line
    Set Line2 = Fact.CreateLine(20, 292, 205, 292)
    Line2.Name = "Line2"
    CATIA.ActiveDocument.Selection.VisProperties.SetRealWidth 3,1
    CATIA.ActiveDocument.Selection.Clear
 
'draw a thin line 
    Set Line3 = Fact.CreateLine(20, 40, 120, 40)
    Line3.Name = "Line3"
    CATIA.ActiveDocument.Selection.Add Line3
    Set visProperties1 = CATIA.ActiveDocument.Selection.VisProperties
    visProperties1.SetRealLineType 1,0.2
    Set visProperties1 = CATIA.ActiveDocument.Selection.VisProperties 
    visProperties1.SetRealWidth 1,0.2

    
    CATIA.ActiveDocument.Selection.Clear
' You can continue to draw the rest of the lines and try other settings...


End Sub 



Regards
Fernando

https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU

RE: Catia drawing. macro for simple geometry

(OP)
before creating of new thread i've tried several macros. looks like inly title block macros can draw simple lines and circles..
with your macro i get an error at following line
Set CATIA = GetObject(, "CATIA.Application")

RE: Catia drawing. macro for simple geometry

For me is working fine in CATScript, for different CATIA versions, on different computers and OS systems (XP or Win 7) with different environments and sort of CATIA installations (clean, nice install, or image deployment).

I could record a video screen capture to show you is OK for me but better then this, check the on line docs (v5automation.chm) to see that getting CATIA object is the best way to start a script (especially when CATIA is deployed from not a well done image and is not registered in Windows registry).


Regards
Fernando

https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources