Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Catia V5/V6 Frame and Title Block CreateSpline

AndersonC

Computer
Feb 20, 2025
2
Hello, I have been struggling with trying to create a spline using v6 vb net macro for the frame and title block. I am very new to this and am trying to create a logo. I have been able to create lines and circles but splines/curves have alluded me. I have tried multiple time, this is my latest attempt.

Code:
    ' Initialize CATIA
    Dim CATIA As Object
    Set CATIA = GetObject(, "CATIA.Application")
    
    ' Access the active drawing document
    Dim drawingDoc As DrawingDocument
    Set drawingDoc = CATIA.ActiveDocument
    
    ' Access the drawing sheet
    Dim drawingSheet As DrawingSheet
    Set drawingSheet = drawingDoc.Sheets.Item(1)
    
    ' Access the drawing view
    Dim drawingView As DrawingView
    Set drawingView = drawingSheet.Views.Item(1)
    
    ' Access the Factory2D
    Dim factory2D As Factory2D
    Set factory2D = drawingView.Factory2D
    
    ' Define the points for the spline
    Dim points(2) As Point2D
    Set points(0) = factory2D.CreatePoint(0, 0)
    Set points(1) = factory2D.CreatePoint(10, 10)
    Set points(2) = factory2D.CreatePoint(20, 0)
    
    ' Create a SafeArray to hold the points
    Dim poles As Variant
    poles = CATIA.CreateObject("CATSafeArrayVariant")
    poles.SetArray points
    
    ' Create the spline
    Dim spline As Spline2D
    Set spline = factory2D.CreateSpline(poles)
    spline.Name = "ProjSpline1"
    
    ' Add the spline to the selection
    MyCATIA.ActiveDocument.Selection.Add spline
    
    ' Set visual properties for the spline
    Dim visProperties1 As VisPropertySet
    Set visProperties1 = MyCATIA.ActiveDocument.Selection.VisProperties
    visProperties1.SetRealWidth 2 * inch, 0.25 * inch
    
    ' Update the drawing
    drawingDoc.Update

Any help with this would be greatly appreciated.
 
Replies continue below

Recommended for you

Hi , i did not searched in documentation , but just saying , it is not easily to bring a picture with the logo ?
 
There is an API to add a picture to a drawing view (I didn't test but it may only support certain file types, so check that if you are having issues):

Function Add(CATBSTR iDrawingPicturePath,double iPositionX,double iPositionY) As DrawingPicture

Inserts a drawing picture in the drawing view and adds it to the DrawingPictures collection.

Parameters:
iDrawingPicturePath

The path of the picture file (ex : "C:\tmp\ball.bmp").

iPositionX, iPositionY
The drawing picture x and y coordinates, expressed in millimeters, with respect to the drawing view coordinate system

Returns: The inserted drawing picture

Example:
The following example inserts a drawing picture from a given picture file path The MyView is the active view in the active drawing sheet

Code:
Dim MySheet As DrawingSheet
Set MySheet = CATIA.ActiveDocument.Sheets.ActiveSheet
Dim MyView As DrawingView
Set MyView = MySheet.Views.ActiveView
Dim MyDrawingPicture1 As DrawingPicture
Set MyDrawingPicture1 = MyView.Pictures.Add("C:\tmp\ball.bmp", 100., 50.)
 

Part and Inventory Search

Sponsor