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


Split spline macro

Split spline macro

Split spline macro

Hi everybody,

I'm working with CATIA since not a long time, and I'm still a little lost, moreover on CATIA automation...The problem is that I want to split a spline (BottomSpline) using a point (ConnectionPoint(6)), and write it in a macro. Here is my code:

        Dim Split1 As Split
    Dim Supref As Reference
    Set Supref = PtPart.CreateReferenceFromObject(ConnectionPoint(6))
    Set Split1 = PtPart.ShapeFactory.AddNewSplit(Supref, BottomSpline)

        Split1.AddElementToKeep BottomSpline

I'm using this 'guide', but honestly I don't understand it pretty well...

I gave as arguments the CuttingElem and the ElemToCut, however, it still gives me an error message, telling me Type Mismatch PtPart.ShapeFactory.AddNewSplit"

What does it mean??

Any help is welcome, thanks in advance,


RE: Split spline macro

I've gone ever to the simplest case, like one line splitted by a point, but it stills gives an error "The method update failed". Actually it fails and the macro works but the splitting operation. Any idea of why does it happen??


Sub CATMain()
    Dim CATIA As Object
    Dim AuxPartDocument As Object

    Set CATIA = CreateObject("CATIA.Application")
    CATIA.Visible = True

    Set AuxPartDocument = CATIA.ActiveDocument
    Set PtDoc = AuxPartDocument
    Set PtPart = PtDoc.Part
    Set PtHybridFactory = PtPart.HybridShapeFactory

    Set PtHybridBody = PtPart.HybridBodies
    Set myPtHybridBody = PtHybridBody.Add
    myPtHybridBody.Name = "Train Geometry"

    Set Point1 = PtPart.HybridShapeFactory.AddNewPointCoord(0,0,0)
    Set Point2 = PtPart.HybridShapeFactory.AddNewPointCoord(10,0,0)
    Set Point3 = PtPart.HybridShapeFactory.AddNewPointCoord(5,0,0)
    myPtHybridBody.AppendHybridShape Point1
    myPtHybridBody.AppendHybridShape Point2
    myPtHybridBody.AppendHybridShape Point3

    Set Spline = PtPart.HybridShapeFactory.AddNewSpline
        Spline.SetSplineType 0
        Spline.SetClosing 0

        Spline.AddPoint Point1
        Spline.AddPoint Point2
    myPtHybridBody.AppendHybridShape Spline
    PtPart.InWorkObject = Spline

    Set mySplit = PtPart.HybridShapeFactory.AddNewHybridSplit(Point3,Spline,1)

    myPtHybridBody.AppendHybridShape mySplit

End Sub

RE: Split spline macro

I update my posts. I already fixed the problem. It was absolutely a stupid task. Actually it has to be first the element to be cut, and then the cutting element, so

Set mySplit = PtPart.HybridShapeFactory.AddNewHybridSplit(Point3,Spline,1)

However, I couldn't manage to split the spline with two points. There is a method, AddCuttingElem

http://catiadoc.free.fr/online/CAAScdBase/CAAScdAutomationHome.htm, but it is applied to the same spline and not to the resulting from point3 cutting. The idea should be then to make a second split operation to that first result, but the problem is that there is no part. I mean, if the spline is L and the cut is done at x, the two parts in theory are x and L-x, but with that function I only get x and L...

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!


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close