1130x
003427
06.08.2019

Création de splines NURBS via l'interface COM

Comment puis-je créer des NURBS avec l'interface COM ?


Réponse:

L'objet principal n'est pas un objet linéique, mais un objet de type NurbSpline.

Voici un court exemple de création d'une NURBS (Non-Uniform Rational B-Spline) :

'--------------------------------------------------------------------------------------------------
Sous nurbs_test()
'--------------------------------------------------------------------------------------------------

    Dim model As RFEM5.model
    Set model = GetObject(, "RFEM5.Model")
    model.GetApplication.LockLicense

    On Error GoTo e

    Dim data As IModelData
    Set data = model.GetModelData

    ' Définir les coordonnées des noeuds
    Dim nodes(0 To 2) As RFEM5.Node
    
    nodes(0).No = 1
    nodes(0).Type = Standard
    nodes(0).CS = Cartesian
    nodes(0).X = 1
    nodes(0).Y = 1
    nodes(0).Z = 0

    nodes(1).No = 2
    nodes(1).Type = Standard
    nodes(1).CS = Cartesian
    nodes(1).X = 2
    nodes(1).Y = 1
    nodes(1).Z = -1
    
    nodes(2).No = 3
    nodes(2).Type = Standard
    nodes(2).CS = Cartesian
    nodes(2).RefObjectNo = 2
    nodes(2).X = 0
    nodes(2).Y = 1
    nodes(2).Z = 0
    
    Dim darr1 (0 To 5) As Double
    darr1(0) = 0
    darr1(1) = 0
    darr1(2) = 0
    darr1(3) = 1
    darr1(4) = 1
    darr1(5) = 1
    
    Dim darr2(0 To 2) As Double
    darr2(0) = 1
    darr2(1) = 1
    darr2(2) = 1
    
    Dim ns As NurbSpline
    ns.General.No = 2
    ns.General.Type = NurbSplineType
    ns.General.NodeList = "1,2,3"
    ns.General.Comment = "Ligne 2"
    ns.Noeuds = darr1
    ns.Ordre = 3
    ns.Weights = darr2
    
    data.PrepareModification
    data.SetNodes nodes
    data.SetNurbSpline ns
e:  data.FinishModification
    If Err.Number <> 0 Then MsgBox Err.description, , Err.Source

    Set data = Nothing
    model.GetApplication.UnlockLicense
    Set model = Nothing

End Sub


Auteur

M. Günthel fournit une assistance technique aux clients de Dlubal Software.

Téléchargements


;