Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Split spline macro

Status
Not open for further replies.

L3munoz

Industrial
Aug 29, 2011
26
0
0
ES
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,

L3munoz
 
Replies continue below

Recommended for you

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??

Language="VBSCRIPT"

Sub CATMain()

Dim CATIA As Object
Dim AuxPartDocument As Object

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

CATIA.Documents.Add("Part")
CATIA.Documents.Item(1).Activate
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

PtPart.Update
End Sub
 
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

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...
 
Status
Not open for further replies.
Back
Top