Je suis nouveau sur TopSolid, je découvre l'API de TopSolid.
A partir de l'aide, j'a réaliser un profil cercle puis je fais une extrusion.
Mais moi je souhaite réaliser une esquisse puis faire une extrusion car c'est plus simple à modifier par la suite.
Je n'ai pas trouver la fonction Esquisse (j'ai cherché avec sketch mais pas de résultat).
est ce qu'il est possible de réaliser une esquisse via API.
Voici le code VBA que j'ai utilisé
Code : Tout sélectionner
Option Explicit
Sub test()
'TopSolid Variable
Dim TopApp As TopSolid.Application
Dim TopDoc As TopSolid.DocumentDesign
Dim TopCircle As TopSolid.Curve
Dim TopShape As TopSolid.Shape
Dim TopElt As TopSolid.Element
'Excel Variable
Dim Rayon As Single, Longueur As Single
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("Feuil1")
Rayon = ws.Range("A2").Value / 1000
Set TopApp = New TopSolid.Application
Set TopDoc = TopApp.Documents.Add("top")
' Create a basic circle
' Centre = 0, 0, 0
' X axis = 1, 0, 0
' Y axis = 0, 1, 0
' Radius = Rayon
Set TopCircle = TopDoc.Curves.AddBasicCircle(0, 0, 0, 1, 0, 0, 0, 1, 0, Rayon)
TopCircle.Element.Name = "Circle_1"
Set TopCircle = Nothing
' Search the curve to do the extruded
Set TopElt = TopDoc.Document.SearchElementByName("Circle_1")
' "cast" the element in circle
Set TopCircle = TopElt
If TopCircle Is Nothing Then
'error management
Exit Sub
End If
' Create a basic extruded
' Curve = Circle 1
' Z axis = 0, 0, 1
' Length = 0.02
Longueur = ws.Range("B2").Value / 1000
Set TopShape = TopDoc.Shapes.AddBasicExtruded(TopCircle, 0, 0, 1, Longueur)
' Change the color of the shape
TopShape.Element.Color = topColorBlue
' Free the memory
Set TopCircle = Nothing
Set TopShape = Nothing
Set TopElt = Nothing
End Sub
Merci d'avance