555x
001811
2019-08-06

[IT] FAQ 003427 | Come posso creare NURBS con l'interfaccia COM?

Domanda:
Come posso creare NURBS con l'interfaccia COM?

Risposta:
L'oggetto principale non è un oggetto linea, ma un oggetto del tipo NurbSpline.
Ecco un breve esempio per la creazione di un NURBS (Non-Uniform Rational B-Spline):

'-------------------------------------------------------------------------- --------------------------------------------------- -
Sub nurbs_test()
'-------------------------------------------------------------------------- --------------------------------------------------- -

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

    On Error GoTo e

    Dim data As IModelData
    Imposta dati = modello.GetModelData

    ' definisce l'array di nodi
    Dim nodes(0 To 2) As RFEM5.Node

    nodi(0).Nr = 1
    nodi(0).Tipo = Standard
    nodi(0).CS = cartesiano
    nodi(0).X = 1
    nodi(0).Y = 1
    nodi(0).Z = 0

    nodi(1).Nr = 2
    nodi(1).Tipo = Standard
    nodi(1).CS = cartesiano
    nodi(1).X = 2
    nodi(1).Y = 1
    nodi(1).Z = -1

    nodi(2).Nr = 3
    nodi(2).Tipo = Standard
    nodi(2).CS = cartesiano
    nodi(2).RefObjectNo = 2
    nodi(2).X = 0
    nodi(2).Y = 1
    nodi(2).Z = 0

    Dim darr1(0 To 5) Come doppio
    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 come NurbSpline
    ns.General.nr = 2
    ns.General.Type = NurbSplineType
    ns.General.NodeList = "1,2,3"
    ns.General.Comment = "riga 2"
    ns.Knots = darr1
    ns.Ordine = 3
    ns.Pesi = darr2

    data.PrepareModificazione
    nodi data.SetNodes
    data.SetNurbSpline ns
e:  data.FinishModulation
    Se Err.Number 0 Then MsgBox Err.Description, , Err.Source

    Imposta dati = Niente
    model.GetApplication.UnlockLicense
    Set model = Nothing

End Sub