Hi nikita,
Zitat:
wie kann ich diese nun mit einem 2d-Spline verbinden? Ich kann nichtmal ein array mit 2 Spaleten (x/y) deklarieren
Übergeben musst ein Array von Punkt-Objekten, also ein-dimensional,
zB.
Dim arrPt2D() 'dynamisches Array von Variants(default) ohne Array-Dimensionen
Nachdem die Punktanzahl bekannt ist(aber vo:
Redim arrPt2D(iNumPt) 'redim ist eine Anweisung, keine Deklaration! iNumPt ist die anzahl der Punkte;
Das Array geht von arrPt2d(0) bis arrPt2d(iNumPt - 1).
Folgende Routine erzeugt 3D-Splines:
Code:
'---------------------------------------------------------------------------------------
' Procedure : CreateSpline
' DateTime : 06.07.2014 01:00
' Author : Joseph Herzog
' Purpose : create a spline using an array of points; no tangents
' Parms : arrPt() - point array
'---------------------------------------------------------------------------------------
'
Sub CreateSpline(arrPt() As HybridShapePointCoord)
Dim n As Integer
Dim ad As Document
Set ad = CATIA.ActiveDocument
Dim adp As Part
Set adp = ad.Part
Dim hSF1 As factory
Set hSF1 = adp.HybridShapeFactory
Dim hSSpl1 As HybridShapeSpline
Set hSSpl1 = hSF1.AddNewSpline()
hSSpl1.SetSplineType 0 'cubic spline
hSSpl1.SetClosing 0 'do not close
Dim hBs1 As hybridBodies
Set hBs1 = adp.hybridBodies Dim hB1 As HybridBody
Set hB1 = hBs1.Item("WireFrame")
Dim Ref1 As Reference
For n = 0 To UBound(arrPt)
Set Ref1 = adp.CreateReferenceFromObject(arrPt(n))
hSSpl1.AddPointWithConstraintExplicit Ref1, Nothing, -1#, 1, Nothing, 0#
Next
hB1.AppendHybridShape hSSpl1
adp.InWorkObject = hSSpl1
hSSpl1.Name = "Route_Spline"
adp.Update
'---------------------------------------------------------------------------------------
'das einfärben muss nach dem update stehen!?!
SetElementColor hSSpl1, 0, 255, 0 'green
End Sub
'---------------------------------------------------------------------------------------
Für 2D läuft's ähnlich.
Die entsprechende Funktion heisst:
Zitat:
aus CAA-Doku:o Func CreateSpline( CATSafeArrayVariant iPoles) As CATIASpline2D
Creates and returns a 2D b-spline.
Parameters:
iPoles
An array of CATIAPoint2D forming the poles of the b-spline.
Allerdings musst das innerhalb eines geöffneten Sketches machen.
Siehe Forumsbeiträge zu Sketch.
Der Makro-Rekorder wird auch was aufzeichnen.
Fang am Besten damit an.
Tschau,
Joe
------------------
Inoffizielle Catia Hilfeseite
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP