ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magicsld/SuperFace.vb
(Generate patch)

Comparing magicsld/SuperFace.vb (file contents):
Revision 40 by bournival, Mon Aug 20 21:30:28 2007 UTC vs.
Revision 205 by bournival, Thu Jul 23 20:53:57 2009 UTC

# Line 1 | Line 1
1 <
1 > Imports SolidWorks.Interop
2 > Imports SolidWorks.Interop.swconst
3 > Imports SolidWorks.Interop.swpublished
4  
5   Public Class SuperFace
6      Inherits SuperEntite
# Line 7 | Line 9 | Public Class SuperFace
9      Private Shared compteur As Long
10      Private Shared no As Long
11  
12 +
13      Friend Flag As Integer = 0 ' = 20 si on a une coupeLong
14  
15  
# Line 40 | Line 43 | Public Class SuperFace
43      ''' <param name="Face"></param>
44      ''' <param name="encapsulateur"></param>
45      ''' <remarks></remarks>
46 <    Public Sub New(ByRef Face As SldWorks.Face2, ByRef encapsulateur As Boolean)
46 >    Public Sub New(ByRef Face As sldworks.Face2, ByRef encapsulateur As Boolean)
47          lst_Faces.Add(Face)
48      End Sub
49  
50 <    Friend Sub New(ByRef face As SldWorks.Face2, Optional ByVal tip As Integer = 0)
50 >    Friend Sub New(ByRef face As sldworks.Face2, Optional ByVal tip As Integer = 0)
51          Me.AjouterFace(face)
52          Select Case tip
53              Case Commun.tipe_e.Volume
# Line 57 | Line 60 | Public Class SuperFace
60      End Sub
61  
62  
63 <    Friend Overridable Function UpdateApresSplit(ByRef inter As InterPoutreCoque, ByRef poutre As SlyAretePoutre, ByRef x As Double, ByRef y As Double, ByRef z As Double, ByRef Plan As SldWorks.RefPlane, Optional ByRef FI As Boolean = False) As SldWorks.Face2
64 <        MsgBox("La fonction non overridée a été appelée!")
65 <        Return Nothing
66 <    End Function
63 >    'Friend Overridable Function UpdateApresSplit(ByRef inter As InterPoutreCoque, ByRef poutre As SlyAretePoutre, ByRef x As Double, ByRef y As Double, ByRef z As Double, ByRef Plan As SldWorks.RefPlane, Optional ByRef FI As Boolean = False) As SldWorks.Face2
64 >    '    MsgBox("La fonction non overridée a été appelée!")
65 >    '    Return Nothing
66 >    'End Function
67  
68 <    Friend Overridable Function UpdateApresSplit(ByRef inter As InterPoutreVolume, ByRef poutre As SlyAretePoutre, ByRef x As Double, ByRef y As Double, ByRef z As Double, ByRef Plan As SldWorks.RefPlane, Optional ByRef FI As Boolean = False) As SldWorks.Face2
69 <        MsgBox("La fonction non overridée a été appelée!")
70 <        Return Nothing
71 <    End Function
68 >    'Friend Overridable Function UpdateApresSplit(ByRef inter As InterPoutreVolume, ByRef poutre As SlyAretePoutre, ByRef x As Double, ByRef y As Double, ByRef z As Double, ByRef Plan As SldWorks.RefPlane, Optional ByRef FI As Boolean = False) As SldWorks.Face2
69 >    '    MsgBox("La fonction non overridée a été appelée!")
70 >    '    Return Nothing
71 >    'End Function
72  
73      ''' <summary>
74 <    ''' Sub qui ajoute des mini-poutres à la section entre le sommet de la poutre et un point de la face interne
74 >    ''' Sub qui ajoute des mini-poutres à la section entre le sommet de la poutre et un point de la face interne quand la face interne ne touche pas à la poutre
75      ''' </summary>
76      ''' <param name="poutre">La poutre principale</param>
77      ''' <param name="FaceInterne">La face où il faut ajouter UNE mini-poutre</param>
# Line 93 | Line 96 | Public Class SuperFace
96          swArete = FaceInterne.GetFirstLoop.GetFirstCoEdge.getedge
97          swSommet2 = swArete.GetStartVertex()
98  
99 <        If swSommet2 Is Nothing Then ' un celcle (ou ellipse)
99 >        If swSommet2 Is Nothing Then ' un cercle (ou ellipse)
100              Dim retval As Object
101              retval = swArete.Evaluate(0) ' il va y avor un LC point anyway...
102              x2 = retval(0)
# Line 112 | Line 115 | Public Class SuperFace
115          '  3 faire une mini-poutre entre les 2
116  
117          swModel.Insert3DSketch2(True)
115        swModel.CreateLine2(x1, y1, z1, x2, y2, z2)
118          swSketch = swModel.GetActiveSketch2()
119 +        If swSketch Is Nothing Then swModel.Insert3DSketch2(True) : swSketch = swModel.GetActiveSketch2()
120 +        If swSketch Is Nothing Then MsgBox("Ça merde vraiment...")
121 +        swModel.CreateLine2(x1, y1, z1, x2, y2, z2)
122          swModel.Insert3DSketch2(True)
123          swEnt = swSketch : swEnt.Select2(False, 1)
124          swModel.InsertCompositeCurve()
# Line 392 | Line 397 | Public Class SuperFace
397      End Sub
398  
399  
400 <    ' sub qui découpe les bords de la face.
396 <    Friend Sub CoupeCote(ByRef inter As InterPoutreVolume, ByRef poutre As SlyAretePoutre)
397 <        Dim pt3() As Double, pt3Original() As Double
398 <        Dim base(2) As Double, baseOriginal(2) As Double
399 <        Dim swEnt As SldWorks.Entity
400 <        Dim Directionnel As Boolean, Flip As Boolean
401 <        Dim planReference As SldWorks.RefPlane = Nothing
402 <        Dim sketchline As SldWorks.SketchSegment
403 <        Dim swSketch As SldWorks.Sketch
404 <        Dim DemiLargeur As Double
405 <        Dim g As Integer
406 <        Dim Face(1) As SldWorks.Face2
407 <        Dim PlanEntity As SldWorks.Entity = Nothing
408 <        Dim r(2) As Double
409 <        Dim sk(1) As Double
410 <        pt3Original = poutre.GetPoint3
411 <
412 <
413 <        swModel.SetInferenceMode(False) ' ne pas mettre de contraintes par défaut
414 <        'swModel.SetAddToDB(True)
415 <        'swModel.SetDisplayWhenAdded(False) ' accélérer les performances
416 <
417 <        Dim vArete As Object
418 <        Dim cut As Double
419 <
420 <        If Me.estPlan Then
421 <            ' la coque est plane, on met une esquisse dessus.#
422 <            PlanEntity = Me.SwFace
423 <
424 <        ElseIf Me.estCylindre Then
425 <            ' on doit créer un plan de référence...
426 <
427 <        ElseIf Me.estFauxPlan(inter.x, inter.y, inter.z) Then
428 <            Dim vEdge As Object
429 <            Dim i As Integer
430 <            Dim swArete2() As SldWorks.Edge
431 <            Dim swSommet As SldWorks.Vertex
432 <
433 <            vEdge = Me.SwFace.GetEdges
434 <            swArete2 = vEdge
435 <            swModel.ClearSelection2(True)
436 <
437 <            While planReference Is Nothing
438 <                If UBound(swArete2) - 2 < i Then MsgBox("Dans CoupeLong, problème pour créer un plan avec 3 points.  (La face est un FauxPlan)", MsgBoxStyle.Critical, "Le plan ne sera pas créé") : Exit While
439 <                swSommet = swArete2(i).GetStartVertex()
440 <                swEnt = swSommet
441 <                swEnt.Select4(False, Nothing)
442 <                swArete2(i + 1).GetStartVertex()
443 <                swEnt = swSommet
444 <                swEnt.Select4(True, Nothing)
445 <                swArete2(i + 2).GetStartVertex()
446 <                swEnt = swSommet
447 <                swEnt.Select4(True, Nothing)
448 <                i += 1
449 <                planReference = swModel.CreatePlaneThru3Points3(False)
450 <                PlanEntity = planReference
451 <            End While
452 <
453 <
454 <        Else ' la face est une spline
455 <            MsgBox("Dans coupeCoté, la face est un type de surface qui n'est pas encore traité")
456 <        End If
457 <
458 <
459 <        baseOriginal(0) = inter.x : baseOriginal(1) = inter.y : baseOriginal(2) = inter.z
460 <
461 <
462 <        Dim Psi As Double
463 <        Dim u(2) As Double, v(2) As Double, usketch(2) As Double, vsketch(2) As Double
464 <        Dim Arete As SldWorks.Edge = Nothing
465 <        Dim retval As Object
466 <        u = poutre.GetOrientation(inter.x, inter.y, inter.z)
467 <
468 <
469 <        vArete = Me.SwFace.GetEdges
470 <
471 <        For Each Arete In vArete
472 <            If Commun.Distance(Arete, inter.x, inter.y, inter.z) < Epsilon Then Exit For
473 <        Next
474 <
475 <        retval = Arete.GetClosestPointOn(inter.x, inter.y, inter.z)
476 <        retval = Arete.Evaluate(retval(3))
477 <        v(0) = retval(3) : v(1) = retval(4) : v(2) = retval(5)
478 <
479 <
480 <
481 <
482 <        For g = 0 To 1
483 <
484 <            PlanEntity.Select(False)
485 <            swModel.InsertSketch2(True)
486 <            swSketch = swModel.GetActiveSketch2
487 <
488 <            pt3 = Commun.TransfertModelSketch(swSketch, pt3Original)
489 <            usketch = Commun.TransfertModelSketch(swSketch, u)  ' on les met dans le plan du sketch
490 <            vsketch = Commun.TransfertModelSketch(swSketch, v)
491 <            base = Commun.TransfertModelSketch(swSketch, baseOriginal)
492 <            Psi = Outils_Math.cosdir(usketch, vsketch)
493 <
494 <            Dim a As Double, b As Double
495 <            'longueur = Math.Sqrt(pt3(0) * pt3(0) + pt3(1) * pt3(1))
496 <            'If pt3(1) = 0 Then a = 999999999999 Else a = Math.Abs(poutre.GetD2() * longueur / pt3(1))
497 <            'If pt3(0) = 0 Then b = 999999999999 Else b = Math.Abs(poutre.GetD1() * longueur / pt3(0))
498 <            ' À revoir. Si le plan est un cylindre ça marche plus. sans compter l'épaisseur de la poutre.
499 <            ' pour l'instant je prend la plus prtite valeur...
500 <            a = poutre.GetD1
501 <            b = poutre.GetD2
502 <            DemiLargeur = Math.Min(a, b)
503 <            cut = DemiLargeur / Math.Sin(Pi / 2 - Psi)
504 <
505 <
506 <            Dim P1(1) As Double
507 <            Dim P2(1) As Double
508 <            Dim P3(1) As Double
509 <            Dim P4(1) As Double
510 <            Dim Ptest(2) As Double
511 <
512 <
513 <            If g = 0 Then
514 <                P1(0) = -cut
515 <                P1(1) = -cut '* mult ' 0
516 <                P2(0) = 0
517 <                P2(1) = -cut '* mult ' 0
518 <                P3(0) = 0
519 <                P3(1) = cut   'Intersections.Taille mult
520 <                P4(0) = -cut
521 <                P4(1) = cut   'Intersections.Taille mult
522 <                sk(0) = -Epsilon * 100 + base(0) : sk(1) = 0 + base(1)
523 <
524 <            Else
525 <                P1(0) = 0
526 <                P1(1) = -cut '* mult '0
527 <                P2(0) = +cut
528 <                P2(1) = -cut '* mult '0
529 <                P3(0) = +cut
530 <                P3(1) = cut  'Intersections.Taille mult
531 <                P4(0) = 0
532 <                P4(1) = cut  'Intersections.Taille mult
533 <                sk(0) = Epsilon * 100 + base(0) : sk(1) = 0 + base(1)
534 <
535 <            End If
536 <
537 <            P1 = Outils_Math.Rotation2D(vsketch, P1)
538 <            P2 = Outils_Math.Rotation2D(vsketch, P2)
539 <            P3 = Outils_Math.Rotation2D(vsketch, P3)
540 <            P4 = Outils_Math.Rotation2D(vsketch, P4)
541 <            sk = Outils_Math.Rotation2D(vsketch, sk)
542 <
543 <            sketchline = swModel.CreateLine2(P1(0) + base(0), P1(1) + base(1), 0, P2(0) + base(0), P2(1) + base(1), 0)
544 <            sketchline = swModel.CreateLine2(P2(0) + base(0), P2(1) + base(1), 0, P3(0) + base(0), P3(1) + base(1), 0)
545 <            sketchline = swModel.CreateLine2(P3(0) + base(0), P3(1) + base(1), 0, P4(0) + base(0), P4(1) + base(1), 0)
546 <            sketchline = swModel.CreateLine2(P1(0) + base(0), P1(1) + base(1), 0, P4(0) + base(0), P4(1) + base(1), 0)
547 <
548 <            swModel.InsertSketch2(True) ' l'option true rebuild le modèle avec les modifications du sketch.
549 <            swModel.ClearSelection2(True)
550 <            swEnt = Me.SwFace : swEnt.Select2(False, 1)
551 <            swEnt = swSketch : swEnt.Select2(True, 4)
552 <
553 <            swModel.InsertSplitLineProject(Directionnel, Flip)
554 <            r = Commun.TransfertSketchToModel(swSketch, sk)
555 <            Face(g) = UpdateApresSplit(inter, poutre, r(0), r(1), r(2), planReference)
556 <            'If Face(g) Is Nothing Then
557 <            'swSketch.Select(False)
558 <            'swModel.EditDelete()
559 <            'End If
560 <
561 <        Next g
562 <
563 <
564 <
565 <        ' mettre les mini-poutres
566 <        Dim vEdge2 As Object
567 <        Dim swArete As SldWorks.Edge
568 <        Dim vPoint As Object
569 <        Dim Mini1 As SldWorks.Edge = Nothing, Mini2 As SldWorks.Edge = Nothing
570 <
571 <
572 <        ' 1 - trouver les 2 arrères dont l'orientation est la même (ou l'inverse) que le v
573 <        For g = 0 To 1
574 <            If Not Face(g) Is Nothing Then
575 <                vEdge2 = Face(g).GetEdges()
576 <
577 <
578 <                ' construire u
579 <                For Each swArete In vEdge2
580 <                    If Commun.Distance(swArete, inter.x, inter.y, inter.z) < Epsilon Then
581 <                        ' l'arête touche à l'intersection,
582 <                        vPoint = swArete.GetClosestPointOn(inter.x, inter.y, inter.z)
583 <                        vPoint = swArete.Evaluate(vPoint(3))
584 <                        u(0) = vPoint(3) : u(1) = vPoint(4) : u(2) = vPoint(5)
585 <
586 <                        If Outils_Math.CompareSens(v, u) Then
587 <                            ' l'arète doit être une mini-poutre
588 <                            If Mini1 Is Nothing Then Mini1 = swArete : Exit For Else Mini2 = swArete : Exit For
589 <                        End If
590 <                    End If
591 <
592 <                Next
593 <
594 <            End If
595 <        Next
596 <
597 <        swEnt = Mini1
598 <        If Not RealConstant.RCCode.CreationAttributPourPoutre(swEnt, "Mini", True) Then MsgBox("A pas marché!")
599 <
600 <        If Not Mini2 Is Nothing Then
601 <            swEnt = Mini2
602 <            If Not RealConstant.RCCode.CreationAttributPourPoutre(swEnt, "Mini", True) Then MsgBox("A pas marché!")
603 <        End If
604 <
605 <        swModel.SetInferenceMode(True) '
606 <        'swModel.SetAddToDB(False)
607 <        'swModel.SetDisplayWhenAdded(True) '
608 <    End Sub
400 >    
401  
402  
403      ' sub qui coupe la face avec une arète qui repose dessus.
404      Friend Sub CoupeLong(ByRef inter As InterPoutreVolume, ByVal poutre As SlyAretePoutre)
613        Dim swEnt As SldWorks.Entity
614        Dim swSketchSegment As SldWorks.SketchSegment
615        Dim vSketchSegments As Object
616        Dim swSketch As SldWorks.Sketch
617        Dim faceinterne(1) As SldWorks.Face2
618        Dim swPlan As SldWorks.RefPlane = Nothing
619        Dim b As Integer
620        Dim swSommet As SldWorks.Vertex
621        Dim i As Integer
622
623        swModel.SetInferenceMode(False) ' ne pas mettre de contraintes par défaut
624
625        ' faut découper toutes les faces de la liste si elles ne sont pas des faces internes
626        Dim MeFace As SldWorks.Face2
627        Dim ListeFace() As SldWorks.Face2
628        ReDim ListeFace(Me.lst_Faces.Count - 1)
629
630        For i = 1 To Me.lst_Faces.Count
631            ListeFace(i - 1) = Me.lst_Faces.Item(i)
632        Next
633
634        For Each MeFace In ListeFace
635
636            If Me.estPlan Then
637                swEnt = MeFace
638                swEnt.Select(False)
639                swPlan = swModel.CreatePlaneAtOffset3(0, False, False)
640                swEnt.Select(False)
641                swModel.InsertSketch2(True)
642
643                swPlan = swModel.CreatePlaneAtOffset3(0, False, False)
644
645            ElseIf Me.estFauxPlan(inter.x, inter.y, inter.z) Then
646                If b = 0 Then
647                    Dim vEdge As Object
648
649
650                    vEdge = MeFace.GetEdges
651                    swModel.ClearSelection2(True)
652                    While swPlan Is Nothing
653                        If UBound(vEdge) - 2 < i Then MsgBox("Dans CoupeLong, problème pour créer un plan avec 3 points.  (La face est un FauxPlan)", MsgBoxStyle.Critical, "Le plan ne sera pas créé") : Exit While
654                        swSommet = vEdge(i).GetStartVertex()
655                        swEnt = swSommet
656                        swEnt.Select4(False, Nothing)
657                        swSommet = vEdge(i + 1).GetStartVertex()
658                        swEnt = swSommet
659                        swEnt.Select4(True, Nothing)
660                        swSommet = vEdge(i + 2).GetStartVertex()
661                        swEnt = swSommet
662                        swEnt.Select4(True, Nothing)
663                        i += 1
664                        swPlan = swModel.CreatePlaneThru3Points3(False)
665
666                    End While
667                End If
668                swEnt = swPlan
669                swEnt.Select(False)
670                swModel.InsertSketch2(True)
671
672            Else
673                MsgBox("Dans coupeLong, on a un type de face qui n'est pas encore traité")
674
675            End If
676
677
678            swSketch = swModel.GetActiveSketch2
679
680            swEnt = poutre.swArete
681            swEnt.Select(False)
405  
683            ' créer la ligne de  «conversion de entités»
684            swModel.SketchUseEdge2(False)
406  
407 <            vSketchSegments = swSketch.GetSketchSegments()
408 <            swSketchSegment = vSketchSegments(0)
409 <            swSketchSegment.Select2(False, 1)  'on sélectionne l'arète de poutre...
407 >        'Dim swEnt As SldWorks.Entity
408 >        'Dim swSketchSegment As SldWorks.SketchSegment
409 >        'Dim vSketchSegments As Object
410 >        'Dim swSketch As SldWorks.Sketch
411 >        'Dim faceinterne(1) As SldWorks.Face2
412 >        'Dim swPlan As SldWorks.RefPlane = Nothing
413 >        'Dim b As Integer
414 >        'Dim swSommet As SldWorks.Vertex
415 >        'Dim i As Integer
416 >
417 >        'swModel.SetInferenceMode(False) ' ne pas mettre de contraintes par défaut
418 >
419 >        '' faut découper toutes les faces de la liste si elles ne sont pas des faces internes
420 >        'Dim MeFace As SldWorks.Face2
421 >        ''Dim ListeFace() As SldWorks.Face2
422 >        ''ReDim ListeFace(Me.lst_Faces.Count - 1)
423 >
424 >        ''For i = 1 To Me.lst_Faces.Count
425 >        ''ListeFace(i - 1) = Me.lst_Faces.Item(i)
426 >        ''Next
427 >
428 >        'For Each MeFace In Me.lst_Faces 'ListeFace
429 >
430 >        '    If Me.estPlan Then
431 >        '        swEnt = MeFace
432 >        '        swEnt.Select(False)
433 >        '        swPlan = swModel.CreatePlaneAtOffset3(0, False, False)
434 >        '        swEnt.Select(False)
435 >        '        swModel.InsertSketch2(True)
436 >
437 >        '        swPlan = swModel.CreatePlaneAtOffset3(0, False, False)
438 >
439 >        '    ElseIf Me.estFauxPlan(inter.x, inter.y, inter.z) Then
440 >        '        If b = 0 Then
441 >        '            Dim vEdge As Object
442 >
443 >
444 >        '            vEdge = MeFace.GetEdges
445 >        '            swModel.ClearSelection2(True)
446 >        '            While swPlan Is Nothing
447 >        '                If UBound(vEdge) - 2 < i Then MsgBox("Dans CoupeLong, problème pour créer un plan avec 3 points.  (La face est un FauxPlan)", MsgBoxStyle.Critical, "Le plan ne sera pas créé") : Exit While
448 >        '                swSommet = vEdge(i).GetStartVertex()
449 >        '                swEnt = swSommet
450 >        '                swEnt.Select4(False, Nothing)
451 >        '                swSommet = vEdge(i + 1).GetStartVertex()
452 >        '                swEnt = swSommet
453 >        '                swEnt.Select4(True, Nothing)
454 >        '                swSommet = vEdge(i + 2).GetStartVertex()
455 >        '                swEnt = swSommet
456 >        '                swEnt.Select4(True, Nothing)
457 >        '                i += 1
458 >        '                swPlan = swModel.CreatePlaneThru3Points3(False)
459 >
460 >        '            End While
461 >        '        End If
462 >        '        swEnt = swPlan
463 >        '        swEnt.Select(False)
464 >        '        swModel.InsertSketch2(True)
465 >
466 >        '    Else
467 >        '        MsgBox("Dans coupeLong, on a un type de face qui n'est pas encore traité")
468 >
469 >        '    End If
470 >
471 >
472 >        '    swSketch = swModel.GetActiveSketch2
473 >
474 >        '    swEnt = poutre.swArete
475 >        '    swEnt.Select(False)
476 >
477 >        '    ' créer la ligne de  «conversion de entités»
478 >        '    swModel.SketchUseEdge2(False)
479 >
480 >        '    vSketchSegments = swSketch.GetSketchSegments()
481 >        '    swSketchSegment = vSketchSegments(0)
482 >        '    swSketchSegment.Select2(False, 1)  'on sélectionne l'arète de poutre...
483 >
484 >        '    Dim x As Double, y As Double, z As Double
485 >        '    Commun.GetMidPointSegment(swSketchSegment, x, y, z)
486 >
487 >
488 >        '    ' sketchoffset doit avoir un mark de 1 pour l'objet à offsetter.  Une valeur négative inverse la direction
489 >        '    swModel.SketchManager.SketchOffset(poutre.GetD2, False, 0, 0, 0, 0)
490 >        '    ' pour rendre le modèle plus beau, on peut enlever la contrainte de offset et laisser solidworks mettre des contraintes automatiques...
491 >
492 >        '    Dim retval As Object
493 >        '    Dim skPointA1 As sldworks.SketchPoint = Nothing, skPointA2 As sldworks.SketchPoint = Nothing, skPointB1 As sldworks.SketchPoint = Nothing, skPointB2 As sldworks.SketchPoint = Nothing
494 >
495 >        '    vSketchSegments = swSketch.GetSketchSegments()
496 >        '    swSketchSegment = vSketchSegments(1)
497 >
498 >
499 >        '    Select Case swSketchSegment.GetType()
500 >        '        Case 0 ' on a une ligne
501 >        '            Dim sketchline As sldworks.SketchLine
502 >        '            sketchline = swSketchSegment
503 >        '            skPointA1 = sketchline.GetStartPoint2
504 >        '            skPointA2 = sketchline.GetEndPoint2()
505 >        '        Case 1 ' arc
506 >        '            Dim arc As sldworks.SketchArc
507 >        '            arc = swSketchSegment
508 >        '            skPointA1 = arc.GetStartPoint
509 >        '            skPointA2 = arc.GetEndPoint2
510 >        '        Case 2 ' ellipse
511 >        '            Dim sketchEllipse As sldworks.SketchEllipse
512 >        '            sketchEllipse = swSketchSegment
513 >        '            skPointA1 = sketchEllipse.GetStartPoint2
514 >        '            skPointA2 = sketchEllipse.GetEndPoint2
515 >        '        Case 3 ' spline
516 >        '            Dim spline As sldworks.SketchSpline
517 >        '            Dim pts() As sldworks.SketchPoint
518 >        '            spline = swSketchSegment
519 >        '            retval = spline.GetPoints2()
520 >        '            pts = retval
521 >        '            skPointA1 = pts(0)
522 >        '            skPointA2 = pts(UBound(pts))
523 >        '        Case 5 ' parabole (le 4 est du texte)
524 >        '            Dim para As sldworks.SketchParabola
525 >        '            para = swSketchSegment
526 >        '            skPointA1 = para.GetStartPoint2
527 >        '            skPointA2 = para.GetEndPoint2
528 >        '    End Select
529 >
530 >        '    swSketchSegment = vSketchSegments(0)
531 >        '    Select Case swSketchSegment.GetType()
532 >        '        Case 0 ' on a une ligne
533 >        '            Dim sketchline As sldworks.SketchLine
534 >        '            sketchline = swSketchSegment
535 >        '            skPointB1 = sketchline.GetStartPoint2
536 >        '            skPointB2 = sketchline.GetEndPoint2()
537 >        '        Case 1 ' arc
538 >        '            Dim arc As sldworks.SketchArc
539 >        '            arc = swSketchSegment
540 >        '            skPointB1 = arc.GetStartPoint
541 >        '            skPointB2 = arc.GetEndPoint2
542 >        '        Case 2 ' ellipse
543 >        '            Dim sketchEllipse As sldworks.SketchEllipse
544 >        '            sketchEllipse = swSketchSegment
545 >        '            skPointB1 = sketchEllipse.GetStartPoint2
546 >        '            skPointB2 = sketchEllipse.GetEndPoint2
547 >        '        Case 3 ' spline
548 >        '            Dim spline As sldworks.SketchSpline
549 >        '            Dim pts() As sldworks.SketchPoint
550 >        '            spline = swSketchSegment
551 >        '            retval = spline.GetPoints2()
552 >        '            pts = retval
553 >        '            skPointB1 = pts(0)
554 >        '            skPointB2 = pts(UBound(pts))
555 >        '        Case 5 ' parabole (le 4 est du texte)
556 >        '            Dim para As sldworks.SketchParabola
557 >        '            para = swSketchSegment
558 >        '            skPointB1 = para.GetStartPoint2
559 >        '            skPointB2 = para.GetEndPoint2
560 >        '    End Select
561 >
562 >        '    ' création des 2 lignes pour fermer le sketch.
563 >        '    swModel.CreateLine2(skPointA1.X, skPointA1.Y, 0, skPointB1.X, skPointB1.Y, 0)
564 >        '    swModel.CreateLine2(skPointA2.X, skPointA2.Y, 0, skPointB2.X, skPointB2.Y, 0)
565 >
566 >
567 >        '    Dim x2 As Double, y2 As Double, z2 As Double ' le midpoint de la poutre
568 >        '    Dim x3 As Double, y3 As Double, z3 As Double ' le midpoint de la poutre
569 >
570 >        '    swSketchSegment = vSketchSegments(0) ' le midpoint d'une poutre
571 >        '    Commun.GetMidPointSegment(swSketchSegment, x2, y2, z2)
572 >
573 >        '    swSketchSegment = vSketchSegments(1) ' le midpoint de l'autre poutre
574 >        '    Commun.GetMidPointSegment(swSketchSegment, x3, y3, z3)
575 >
576 >        '    Dim sk(1) As Double, r(2) As Double
577 >        '    sk(0) = (x3 + x2) / 2
578 >        '    sk(1) = (y3 + y2) / 2
579 >        '    r = Commun.TransfertSketchToModel(swSketch, sk)
580 >
581 >        '    swModel.InsertSketch2(True) ' l'option true rebuild le modèle avec les modifications du sketch.
582 >        '    swModel.ClearSelection2(True)
583 >        '    swEnt = MeFace : swEnt.Select2(False, 1)
584 >        '    swEnt = swSketch : swEnt.Select2(True, 4)
585 >
586 >        '    swModel.InsertSplitLineProject(False, False)
587 >
588 >        '    Me.Flag = 20 ' pour dire que l'on a un coupeLong
589 >        '    faceinterne(b) = UpdateApresSplit(inter, poutre, r(0), r(1), r(2), swPlan) ' et ça s'occupe de créer la coque... mais je suis pas certain que c'est nécessaire
590 >        '    Me.Flag = 0
591  
690            Dim x As Double, y As Double, z As Double
691            Commun.GetMidPointSegment(swSketchSegment, x, y, z)
692
693
694            ' sketchoffset doit avoir un mark de 1 pour l'objet à offsetter.  Une valeur négative inverse la direction
695            swModel.SketchManager.SketchOffset(poutre.GetD2, False, 0, 0, 0, 0)
696            ' pour rendre le modèle plus beau, on peut enlever la contrainte de offset et laisser solidworks mettre des contraintes automatiques...
697
698            Dim retval As Object
699            Dim skPointA1 As SldWorks.SketchPoint = Nothing, skPointA2 As SldWorks.SketchPoint = Nothing, skPointB1 As SldWorks.SketchPoint = Nothing, skPointB2 As SldWorks.SketchPoint = Nothing
700
701            vSketchSegments = swSketch.GetSketchSegments()
702            swSketchSegment = vSketchSegments(1)
703
704
705            Select Case swSketchSegment.GetType()
706                Case 0 ' on a une ligne
707                    Dim sketchline As SldWorks.SketchLine
708                    sketchline = swSketchSegment
709                    skPointA1 = sketchline.GetStartPoint2
710                    skPointA2 = sketchline.GetEndPoint2()
711                Case 1 ' arc
712                    Dim arc As SldWorks.SketchArc
713                    arc = swSketchSegment
714                    skPointA1 = arc.GetStartPoint
715                    skPointA2 = arc.GetEndPoint2
716                Case 2 ' ellipse
717                    Dim sketchEllipse As SldWorks.SketchEllipse
718                    sketchEllipse = swSketchSegment
719                    skPointA1 = sketchEllipse.GetStartPoint2
720                    skPointA2 = sketchEllipse.GetEndPoint2
721                Case 3 ' spline
722                    Dim spline As SldWorks.SketchSpline
723                    Dim pts() As SldWorks.SketchPoint
724                    spline = swSketchSegment
725                    retval = spline.GetPoints2()
726                    pts = retval
727                    skPointA1 = pts(0)
728                    skPointA2 = pts(UBound(pts))
729                Case 5 ' parabole (le 4 est du texte)
730                    Dim para As SldWorks.SketchParabola
731                    para = swSketchSegment
732                    skPointA1 = para.GetStartPoint2
733                    skPointA2 = para.GetEndPoint2
734            End Select
735
736            swSketchSegment = vSketchSegments(0)
737            Select Case swSketchSegment.GetType()
738                Case 0 ' on a une ligne
739                    Dim sketchline As SldWorks.SketchLine
740                    sketchline = swSketchSegment
741                    skPointB1 = sketchline.GetStartPoint2
742                    skPointB2 = sketchline.GetEndPoint2()
743                Case 1 ' arc
744                    Dim arc As SldWorks.SketchArc
745                    arc = swSketchSegment
746                    skPointB1 = arc.GetStartPoint
747                    skPointB2 = arc.GetEndPoint2
748                Case 2 ' ellipse
749                    Dim sketchEllipse As SldWorks.SketchEllipse
750                    sketchEllipse = swSketchSegment
751                    skPointB1 = sketchEllipse.GetStartPoint2
752                    skPointB2 = sketchEllipse.GetEndPoint2
753                Case 3 ' spline
754                    Dim spline As SldWorks.SketchSpline
755                    Dim pts() As SldWorks.SketchPoint
756                    spline = swSketchSegment
757                    retval = spline.GetPoints2()
758                    pts = retval
759                    skPointB1 = pts(0)
760                    skPointB2 = pts(UBound(pts))
761                Case 5 ' parabole (le 4 est du texte)
762                    Dim para As SldWorks.SketchParabola
763                    para = swSketchSegment
764                    skPointB1 = para.GetStartPoint2
765                    skPointB2 = para.GetEndPoint2
766            End Select
767
768            ' création des 2 lignes pour fermer le sketch.
769            swModel.CreateLine2(skPointA1.X, skPointA1.Y, 0, skPointB1.X, skPointB1.Y, 0)
770            swModel.CreateLine2(skPointA2.X, skPointA2.Y, 0, skPointB2.X, skPointB2.Y, 0)
771
772
773            Dim x2 As Double, y2 As Double, z2 As Double ' le midpoint de la poutre
774            Dim x3 As Double, y3 As Double, z3 As Double ' le midpoint de la poutre
775
776            swSketchSegment = vSketchSegments(0) ' le midpoint d'une poutre
777            Commun.GetMidPointSegment(swSketchSegment, x2, y2, z2)
778
779            swSketchSegment = vSketchSegments(1) ' le midpoint de l'autre poutre
780            Commun.GetMidPointSegment(swSketchSegment, x3, y3, z3)
781
782            Dim sk(1) As Double, r(2) As Double
783            sk(0) = (x3 + x2) / 2
784            sk(1) = (y3 + y2) / 2
785            r = Commun.TransfertSketchToModel(swSketch, sk)
786
787            swModel.InsertSketch2(True) ' l'option true rebuild le modèle avec les modifications du sketch.
788            swModel.ClearSelection2(True)
789            swEnt = MeFace : swEnt.Select2(False, 1)
790            swEnt = swSketch : swEnt.Select2(True, 4)
791
792            swModel.InsertSplitLineProject(False, False)
793
794            Me.Flag = 20 ' pour dire que l'on a un coupeLong
795            faceinterne(b) = UpdateApresSplit(inter, poutre, r(0), r(1), r(2), swPlan) ' et ça s'occupe de créer la coque... mais je suis pas certain que c'est nécessaire
796            Me.Flag = 0
797
798            'If faceinterne(b) Is Nothing Then
799            'swEnt = swSketch
800            'swEnt.Select(False)
801            'swModel.EditDelete()
802            'End If
803
804
805
806            ' reste à updater, on doit ajouter de 2 à 4 mini-poutres
807            'Dim vEdges As Object
808            'Dim Arete As SldWorks.Edge
809            'Dim vFaces As Object
810            'Dim aretePoutre As SldWorks.Edge
811
812
813            ''For b = 0 To 1
814            ''If Not faceinterne(b) Is Nothing Then
815            'b = 0
816            'While faceinterne(b) Is Nothing
817            '    b += 1
818            'End While
819
820            'vEdges = faceinterne(b).GetEdges
821            'For Each Arete In vEdges
822            '    If Distance(Arete.GetStartVertex, inter.x, inter.y, inter.z) < Epsilon Then swSommet = Arete.GetStartVertex : Exit For
823            '    If Distance(Arete.GetEndVertex, inter.x, inter.y, inter.z) < Epsilon Then swSommet = Arete.GetEndVertex : Exit For
824            'Next
825
826            'Dim T As Double
827            'Dim xyz(2) As Double
828            'Dim g As Integer
829            'Dim courbe As SldWorks.Curve
830
831            'T = poutre.GetT(inter.x, inter.y, inter.z)
832
833            'vEdges = swSommet.GetEdges
834
835            'T -= 10000 * Epsilon
836
837            'For g = 0 To UBound(vEdges) ' boucle pas optimisée en vitesse
838            '    Arete = vEdges(g)
839            '    If poutre.Evaluer(T, xyz) Then
840            '        courbe = Arete.GetCurve
841            '        If Distance(courbe, xyz(0), xyz(1), xyz(2)) < Epsilon Then aretePoutre = Arete
842            '    ElseIf poutre.Evaluer(T + 20000 * Epsilon, xyz) Then
843            '        courbe = Arete.GetCurve
844            '        If Distance(courbe, xyz(0), xyz(1), xyz(2)) < Epsilon Then aretePoutre = Arete ' la distance devrait être entre la droite (et non l'arête) et le point.
845            '    End If
846            'Next g
847
848
849            'If aretePoutre Is Nothing Then
850            '    ' putain d'enfoiré de merde!!!! on trouve pas la courbe de la poutre. alors on sort avec dignité!
851            '    Exit Sub
852            '    ' anyway on avait dit en réunion de ne pas mettre de minipoutres...
853            'End If
854
855
856            '' on a l'arète de la poutre, avec la boucle de la face on prend une arète avant et une arête après.
857            'Dim swBoucle As SldWorks.Loop2
858            'Dim AreteAvant As SldWorks.Edge, AreteSuivant As SldWorks.Edge, areteTest As SldWorks.Edge
859            'Dim varete As Object
860            'Dim Mini1 As SldWorks.Edge, Mini2 As SldWorks.Edge, Mini3 As SldWorks.Edge, Mini4 As SldWorks.Edge
861
862            'Dim j As Integer
863
864            'If Not faceinterne(0) Is Nothing Then
865            '    swBoucle = faceinterne(0).GetFirstLoop ' devrait y en avoir juste une...
866            '    varete = swBoucle.GetEdges()
867
868            '    For j = 0 To UBound(varete)
869            '        areteTest = varete(j)
870            '        If areteTest Is aretePoutre Then
871            '            If j <> 0 Then Mini1 = varete(j - 1) Else Mini1 = varete(UBound(varete))
872            '            If j <> UBound(varete) Then Mini2 = varete(j + 1) Else Mini2 = varete(0)
873            '        End If
874            '    Next j
875            'End If
876
877            'If Not faceinterne(1) Is Nothing Then
878            '    swBoucle = faceinterne(1).GetFirstLoop ' devrait y en avoir juste une...
879            '    varete = swBoucle.GetEdges()
880
881            '    For j = 0 To UBound(varete)
882            '        areteTest = varete(j)
883            '        If areteTest Is aretePoutre Then
884            '            If j <> 0 Then Mini3 = varete(j - 1) Else Mini3 = varete(UBound(varete))
885            '            If j <> UBound(varete) Then Mini4 = varete(j + 1) Else Mini4 = varete(0)
886            '        End If
887            '    Next j
888            'End If
889            'If Not Mini1 Is Nothing Then
890            '    swEnt = Mini1
891            '    If Not RealConstant.RCCode.CreationAttributPourPoutre(swEnt, "Mini", True) Then MsgBox("A pas marché!")
892            'End If
893
894            'If Not Mini2 Is Nothing Then
895            '    swEnt = Mini2
896            '    If Not RealConstant.RCCode.CreationAttributPourPoutre(swEnt, "Mini", True) Then MsgBox("A pas marché!")
897            'End If
898
899            'If Not Mini3 Is Nothing Then
900            '    swEnt = Mini3
901            '    If Not RealConstant.RCCode.CreationAttributPourPoutre(swEnt, "Mini", True) Then MsgBox("A pas marché!")
902            'End If
903
904            'If Not Mini4 Is Nothing Then
905            '    swEnt = Mini4
906            '    If Not RealConstant.RCCode.CreationAttributPourPoutre(swEnt, "Mini", True) Then MsgBox("A pas marché!")
907            'End If
908        Next MeFace
909
910
911        swModel.SetInferenceMode(True) ' ne pas mettre de contraintes par défaut
912        'swModel.SetAddToDB(False)
913        'swModel.SetDisplayWhenAdded(True) ' accélérer les performances
592  
593      End Sub
594  
595  
918    ' sub qui coupe la face normalement, avec un X.... [cas #1]
919    Friend Sub CoupeX(ByRef inter As InterPoutreVolume, ByRef poutre As SlyAretePoutre)
920
921        Dim swEnt As SldWorks.Entity = Nothing
922        Dim Directionnel As Boolean, Flip As Boolean
923        Dim Faces(3) As SldWorks.Face2
924        Dim r(2) As Double
925        Dim LaSurface As SldWorks.Surface
926        Dim sens As Boolean
927        Dim p(2) As Double
928        Dim retour() As Double
929
930        swModel.SetInferenceMode(False) ' ne pas mettre de contraintes par défaut
931        'swModel.SetAddToDB(True)
932        'swModel.SetDisplayWhenAdded(False) ' accélérer les performances
933
934
935        ' l'idée est de sélectionner le point et l'arète puis d'utiliser CreatePlanePerCurveAndPassPoint3
936        Dim planReference As SldWorks.RefPlane
937        Dim swsketch As SldWorks.Sketch
938        Dim swSommet As SldWorks.Vertex, swSommet2 As SldWorks.Vertex
939        Dim pointdeb(2) As Double, pointfin(2) As Double
940
941        'swModel.Extension.SelectByID2("", "POINTREF", inter.x, inter.y, inter.z, False, 0, Nothing, 0)
942        ' faut vraiment sélectionner le bon point...
943        swSommet = poutre.swArete.GetStartVertex()
944        swSommet2 = poutre.swArete.GetEndVertex()
945        If swSommet Is Nothing Then
946            MsgBox("On a un cercle ou courbe sans sommets, dans coupeX, pas encore traité.  Ne peut pas mettre un plan si pas de sommet")
947        Else
948            If Distance(swSommet, inter.x, inter.y, inter.z) < Epsilon Then
949                swEnt = swSommet
950            ElseIf Distance(swSommet2, inter.x, inter.y, inter.z) < Epsilon Then
951                swEnt = swSommet2
952            Else
953                MsgBox("Dans coupeX, l'intersection n'est pas sur un sommet.  Pas encore traité.  Nécessite de créer un point au coordonnées d'intersection")
954            End If
955        End If
956
957        swEnt.Select4(False, Nothing)
958        swEnt = poutre.swArete
959        swEnt.Select(True)
960
961        If Me.estPlan Or Me.estFauxPlan(inter.x, inter.y, inter.z) Then
962            ' si la coque est plane alors on projette le plan de référence des deux cotés, sinon on doit le décaler vers le bas
963            planReference = swModel.CreatePlanePerCurveAndPassPoint3(True, True)
964            Directionnel = False
965            Flip = False
966        ElseIf Me.estCylindre Then
967            ' on a un cylindre, on ne projette pas des 2 cotés.  On créé un plan, puis un autre plus bas pour ensuite projeter d'un seul coté.
968            Dim PlanDessus As SldWorks.RefPlane
969            Dim Rayon As Double, L As Double, B As Double, phi As Double, dist As Double, temp1 As Double, temp2 As Double
970            Dim u(2) As Double, v(2) As Double
971            PlanDessus = swModel.CreatePlanePerCurveAndPassPoint3(True, True)
972            temp1 = poutre.GetD1
973            temp2 = poutre.GetD2
974            L = Math.Sqrt(temp1 * temp1 + temp2 * temp2)
975            Rayon = Me.GetRayonCylindre()
976            u = poutre.GetOrientation(inter.x, inter.y, inter.z)
977            v = Me.GetNormale(inter.x, inter.y, inter.z)
978            phi = -(Math.Acos(Outils_Math.cosdir(u, v)))
979            B = Math.Abs(L / 2 * Math.Sin(phi))
980            dist = Rayon - Math.Sqrt(Rayon * Rayon - ((L / 2) * (L / 2))) + B
981            If dist < 0 Then MsgBox("Gros problème pour couper le cylindre, la poutre est plus grosse!!!!!!", MsgBoxStyle.Critical) : Exit Sub
982
983            swEnt = PlanDessus
984            swEnt.Select(False)
985            Directionnel = True
986
987            Flip = Flipper(PlanDessus, inter)
988
989            planReference = swModel.CreatePlaneAtOffset3(dist * 2, Flip, True)
990        Else
991            MsgBox("La coque n'est ni un cylindre, ni un plan" & vbCr & "Le résultat n'est pas certain...", MsgBoxStyle.Information, "Avertissement")
992            planReference = swModel.CreatePlanePerCurveAndPassPoint3(True, True)
993            Directionnel = False
994            Flip = False
995        End If
996
997
998
999        LaSurface = Me.SwFace.GetSurface()
1000        sens = Me.SwFace.FaceInSurfaceSense()
1001
1002        ' skx est la coordonnée du point de ref en coord de sketch, Rx est le point de référence dans le repère global.
1003        Dim i As Integer, MettreFI As Boolean
1004        Dim swFeat As SldWorks.Feature
1005
1006        For i = 0 To 1
1007
1008            swEnt = planReference
1009            swEnt.Select(False)
1010            swModel.InsertSketch2(False)
1011            swModel.ClearSelection2(True)
1012            swFeat = swModel.FeatureByPositionReverse(0)
1013            swModel.SelectByID(swFeat.Name, "SKETCH", 0, 0, 0)
1014            swModel.EditSketch()
1015            swsketch = swModel.GetActiveSketch2
1016
1017            p(0) = inter.x : p(1) = inter.y : p(2) = inter.z
1018            retour = Commun.TransfertModelSketch(swsketch, p)
1019
1020
1021            r = DessineSectionPoutre(poutre, retour(0), retour(1), i + 1, swsketch, inter, MettreFI)
1022            swModel.InsertSketch2(True) ' l'option true rebuild le modèle avec les modifications du sketch.
1023            swModel.ClearSelection2(True)
1024
1025            Dim face As SldWorks.Face2
1026            For Each face In Me.lst_Faces
1027                swModel.ClearSelection2(True)
1028                swEnt = face : swEnt.Select2(False, 1)
1029                swEnt = swsketch : swEnt.Select2(True, 4)
1030                swModel.InsertSplitLineProject(Directionnel, Flip)
1031            Next
1032
1033
1034            Me.SwFace.DetachSurface()
1035            Me.SwFace.AttachSurface(LaSurface, sens)
1036
1037            Faces(i) = UpdateApresSplit(inter, poutre, r(0), r(1), r(2), planReference, MettreFI)
1038            Commun.MettreUnPoint(r(0), r(1), r(2))
1039
1040            If Faces(i) Is Nothing Then
1041                swEnt.Select(False)
1042                swModel.EditDelete()
1043            End If
1044            If Flag = 2 Then Flag = 0 : Exit For
1045
1046        Next i
1047
1048        swModel.SetInferenceMode(True)
1049        'swModel.SetAddToDB(False)
1050        'swModel.SetDisplayWhenAdded(True)
596  
597 +    ''' <summary>
598 +    ''' Sub qui appelle le découpage de la face
599 +    ''' </summary>
600 +    ''' <remarks>On devrait revoir cette sub en fonction des nouveaux outils de VB2005</remarks>
601 +    Public Overridable Sub decouper()
602 +        MsgBox("La fonction non Overridé a été appelée!")
603      End Sub
604  
605  
606 <    ' Sub qui appelle le découpage de la face
607 <    Public Sub decouper()
608 <
609 <        If lst_InterPoutre.Count = 0 Then Exit Sub ' sortir si on a pas d'intersection
610 <
611 <
612 <        ' les attributs ne sont pas updatés sur les faces (mais sur les arètes et les sommets c'est OK)
613 <        ' on mémorise l'attribut de la face et on la réapplique à la fin.
614 <
615 <
616 <        Dim i As Integer
617 <        Dim inter As InterPoutreVolume
618 <        Dim nb1 As Integer, nb2 As Integer, nb3 As Integer, nb5 As Integer
619 <        Dim poutre1 As SlyAretePoutre = Nothing, poutre3 As SlyAretePoutre = Nothing
620 <        Dim lst_poutre2 As New Collection
621 <        Dim aire As Double
622 <        Dim poutreTest As SlyAretePoutre
623 <
1073 <        Dim lst_coupeXinter As New Collection
1074 <        Dim lst_coupeXPoutre As New Collection
1075 <        Dim lst_coupeLinter As New Collection
1076 <        Dim lst_coupeLPoutre As New Collection
1077 <        Dim lst_coupeCinter As New Collection
1078 <        Dim lst_coupeCPoutre As New Collection
1079 <
1080 <
1081 <        For Each inter In lst_InterPoutre
1082 <
1083 <            'pour chaque intersection on peut avoir plusieurs poutres...
1084 <            For i = 1 To inter.lst_sPoutre.Count
1085 <                poutreTest = inter.lst_sPoutre.Item(i)
1086 <                Select Case CInt(inter.lst_type.Item(i))
1087 <                    Case 1
1088 <                        If poutreTest.GetAireCarree > aire Then poutre1 = poutreTest
1089 <                        nb1 += 1
1090 <                    Case 2
1091 <                        lst_poutre2.Add(poutreTest)
1092 <                        nb2 += 1
1093 <                    Case 3
1094 <                        If poutreTest.GetAireCarree > aire Then poutre3 = poutreTest
1095 <                        nb3 += 1
1096 <                    Case 5 ' un poutre à faceDeSection
1097 <                        nb5 += 1
1098 <                    Case 22
1099 <                        ' on fait rien, mais c'est pour éviter le msgbox du case else...
1100 <                    Case Else
1101 <                        MsgBox("Problème dans découper de SlyFaceCoque, le type d'intersection n'est pas reconnu", MsgBoxStyle.Critical)
1102 <                End Select
1103 <            Next i
1104 <
1105 <
1106 <
1107 <            If nb1 > 0 Then 'CoupeX(inter, poutre1) ' on coupe le x en premier
1108 <                lst_coupeXinter.Add(inter)
1109 <                lst_coupeXPoutre.Add(poutre1)
1110 <            End If
1111 <
1112 <
1113 <            For Each poutreTest In lst_poutre2 ' puis on coupe sur la longueur 'CoupeLong(inter, poutreTest)
1114 <                lst_coupeLinter.Add(inter)
1115 <                lst_coupeLPoutre.Add(poutreTest)
606 >    ''' <summary>
607 >    ''' Renvoie le nombre d'arêtes dans la face principale
608 >    ''' </summary>
609 >    ''' <value></value>
610 >    ''' <returns></returns>
611 >    ''' <remarks></remarks>
612 >    Public ReadOnly Property NbSommets() As Integer
613 >        Get
614 >            Dim lst_sommets As New Collections.Generic.List(Of sldworks.Vertex)
615 >            Dim swSommet As sldworks.Vertex = Nothing
616 >            Dim vedges As Object = Me.SwFace.GetEdges
617 >            For Each edge As sldworks.Edge In vedges
618 >                swSommet = edge.GetStartVertex
619 >                If swSommet IsNot Nothing Then
620 >                    lst_sommets.Add(swSommet)
621 >                    swSommet = edge.GetEndVertex
622 >                    lst_sommets.Add(swSommet)
623 >                End If
624              Next
625 +            Return lst_sommets.Count
626 +        End Get
627 +    End Property
628  
629 <            If nb3 > 0 Then 'CoupeCote(inter, poutre3) ' finalement on coupe sur les cotés
630 <                lst_coupeCinter.Add(inter)
631 <                lst_coupeCPoutre.Add(poutre3)
632 <            End If
633 <
634 <            If nb5 = 1 And (nb1 > 0 Or nb2 > 0 Or nb3 > 0) Then
635 <                MsgBox("Problème, on a un type d'intersection impossible dans la vraie vie!", MsgBoxStyle.Exclamation, "Design impossible à obtenir en réalité...")
1125 <            End If
1126 <
1127 <
1128 <            lst_poutre2.Clear()
1129 <            nb1 = 0 : nb2 = 0 : nb3 = 0
1130 <
1131 <
1132 <        Next inter
1133 <
1134 <
1135 <        ' maintenant on a toutes les lists d'intersections.  On les coupe.
1136 <        For i = 1 To lst_coupeXinter.Count
1137 <            CoupeX(lst_coupeXinter.Item(i), lst_coupeXPoutre.Item(i))
1138 <        Next
1139 <
1140 <        For i = 1 To lst_coupeLinter.Count
1141 <            CoupeLong(lst_coupeLinter.Item(i), lst_coupeLPoutre.Item(i))
1142 <        Next
1143 <
1144 <        For i = 1 To lst_coupeCinter.Count
1145 <            CoupeCote(lst_coupeCinter.Item(i), lst_coupeCPoutre.Item(i))
1146 <        Next
1147 <        If nb5 = 1 Then
1148 <            If lst_InterPoutre.Count <> 1 Then MsgBox("Plus d'une intersection du type FacedeSection....")
1149 <            CoupeFaceDeSection(lst_InterPoutre(1))
1150 <        End If
1151 <
1152 <    End Sub
1153 <
1154 <    Private Sub CoupeFaceDeSection(ByRef inter As InterPoutreVolume)
1155 <        Dim swEnt As SldWorks.Entity = Nothing
629 >    ''' <summary>
630 >    ''' Coupe si nécesaire la face lorsque l'on a une poutre avec face de section.  À noter que si l'on coupe c'est avec un angle de pi / 8
631 >    ''' </summary>
632 >    ''' <param name="inter"></param>
633 >    ''' <remarks></remarks>
634 >    Protected Sub CoupeFaceDeSection(ByRef inter As InterPoutreVolume)
635 >        Dim swEnt As sldworks.Entity = Nothing
636          Dim Directionnel As Boolean
637 <        Dim Faces(3) As SldWorks.Face2
637 >        Dim Faces(3) As sldworks.Face2
638          Dim r(2) As Double
639          Dim p(2) As Double
640 <        Dim planReference As SldWorks.RefPlane = Nothing
641 <        Dim swsketch As SldWorks.Sketch
640 >        Dim planReference As sldworks.RefPlane = Nothing
641 >        Dim swsketch As sldworks.Sketch
642          Dim pointdeb(2) As Double, pointfin(2) As Double
643 <        Dim sketchline As SldWorks.SketchLine
644 <        Dim swFeat As SldWorks.Feature
643 >        Dim sketchline As sldworks.SketchLine
644 >        Dim swFeat As sldworks.Feature
645  
646  
647          swModel.SetInferenceMode(False) ' ne pas mettre de contraintes par défaut
# Line 1171 | Line 651 | Public Class SuperFace
651          swModel.InsertSketch2(False)
652          swsketch = swModel.GetActiveSketch2
653  
654 <        ' dessin de la forme à faire...
655 <
1176 <        Dim xyzc() As Double, xyz(2) As Double
1177 <        xyz(0) = inter.x : xyz(1) = inter.y : xyz(2) = inter.z
1178 <        xyzc = Commun.TransfertModelSketch(swsketch, xyz)
654 >        ' dessin de la forme à faire SI NÉCESSAIRE
655 >        If Me.NbSommets = 0 OrElse Distance(Me.SwFace, inter.x, inter.y, inter.z) < Epsilon Then
656  
657 <        sketchline = swModel.CreateLine2(xyzc(0), xyzc(1), 0, xyzc(0) + Math.Cos(Pi / 4), xyzc(1) + Math.Sin(Pi / 4), 0)
658 <        sketchline = swModel.CreateLine2(xyzc(0), xyzc(1), 0, xyzc(0) - Math.Cos(Pi / 4), xyzc(1) + Math.Sin(Pi / 4), 0)
659 <        swModel.CreateArc2(xyzc(0), xyzc(1), 0, xyzc(0) + Math.Cos(Pi / 4), xyzc(1) + Math.Sin(Pi / 4), 0, xyzc(0) - Math.Cos(Pi / 4), xyzc(1) + Math.Sin(Pi / 4), 0, 1) ' le dernier param est la direction.  1 ou -1
657 >            Dim xyzc() As Double, xyz(2) As Double
658 >            xyz(0) = inter.x : xyz(1) = inter.y : xyz(2) = inter.z
659 >            xyzc = Commun.TransfertModelSketch(swsketch, xyz)
660 >
661 >            sketchline = swModel.CreateLine2(xyzc(0), xyzc(1), 0, xyzc(0) + Math.Cos(Pi / 8), xyzc(1) + Math.Sin(Pi / 8), 0)
662 >            sketchline = swModel.CreateLine2(xyzc(0), xyzc(1), 0, xyzc(0) - Math.Cos(Pi / 8), xyzc(1) + Math.Sin(Pi / 8), 0)
663 >            swModel.CreateArc2(xyzc(0), xyzc(1), 0, xyzc(0) + Math.Cos(Pi / 8), xyzc(1) + Math.Sin(Pi / 8), 0, xyzc(0) - Math.Cos(Pi / 8), xyzc(1) + Math.Sin(Pi / 8), 0, 1) ' le dernier param est la direction.  1 ou -1
664  
665 <        swModel.InsertSketch2(True) ' l'option true rebuild le modèle avec les modifications du sketch.
666 <        swModel.ClearSelection2(True)
665 >            swModel.InsertSketch2(True) ' l'option true rebuild le modèle avec les modifications du sketch.
666 >            swModel.ClearSelection2(True)
667  
668 <        swEnt = Me.SwFace : swEnt.Select2(False, 1)
669 <        swEnt = swsketch : swEnt.Select2(True, 4)
670 <        swModel.InsertSplitLineProject(Directionnel, False)
668 >            swEnt = Me.SwFace : swEnt.Select2(False, 1)
669 >            swEnt = swsketch : swEnt.Select2(True, 4)
670 >            swModel.InsertSplitLineProject(Directionnel, False)
671  
672  
673 <        ' flagger les 2 faces comme faces Internes.
674 <        Dim vface As Object
675 <        Dim face As SldWorks.Face2
676 <        Dim attr As SldWorks.Attribute
677 <        swFeat = swModel.FeatureByPositionReverse(0)
678 <        Try
679 <            vface = swFeat.GetFaces
680 <            For Each face In vface
681 <                '**************
682 <                Dim nom2 As String = "FaceInterne" & no
683 <                swEnt = face
684 <                attr = swEnt.FindAttribute(Intersections.DefAttrFaceInterne, 0) ' si l'attribut existe déjà on pointe dessus.
685 <                If attr Is Nothing Then attr = Intersections.DefAttrFaceInterne.CreateInstance5(swModel, face, nom2, 0, 2) ' 0 = swThisconfig
686 <                While attr Is Nothing
687 <                    no += 1
688 <                    nom2 = "FaceInterne" & CStr(no)
689 <                    attr = Intersections.DefAttrFaceInterne.CreateInstance5(swModel, face, nom2, 0, 2)
690 <                End While
691 <                GererDossiers("FaceInternes", nom2)
692 <                no += 1
1212 <
1213 <
1214 <                '**************
1215 <                Me.AjouterFace(face)
1216 <            Next face
1217 <        Catch
1218 <            ' si on a une poutre dessinée en partie, on aura pas de feature... mais on a la face...
1219 <            ' on doit donc le déterminer anyway
1220 <        End Try
673 >            ' flagger les 2 faces comme faces Internes.
674 >            Dim vface As Object
675 >            Dim face As sldworks.Face2 = Nothing
676 >            swFeat = swModel.FeatureByPositionReverse(0)
677 >            Try
678 >                vface = swFeat.GetFaces
679 >                For Each face In vface
680 >                    no = Me.MettreAttributFaceInterne(face, 2 * Me.Aire / Me.Perimetre, True) ' plus certain que l'on a besoin du numéro
681 >                    Me.AjouterFace(face)
682 >                Next face
683 >            Catch
684 >                ' si on a une poutre dessinée en partie, on aura pas de feature... mais on a la face...
685 >                ' on doit donc le déterminer anyway
686 >            End Try
687 >
688 >            ' si ça ne touche pas à la face
689 >            If Not Distance(Me.SwFace, inter.x, inter.y, inter.z) < Epsilon Then
690 >                AjouterMiniPoutresSurFaceInterne(inter.lst_sPoutre.Item(1), face, inter.x, inter.y, inter.z)
691 >                'MsgBox("On ajoute une mini-poutre entre la poutre " & inter.lst_sPoutre.Item(1).nom & vbCr & " et le point ( " & Format(inter.x * 1000, "0000") & " , " & Format(inter.y * 1000, "0000") & " , " & Format(inter.y * 1000, "0000") & " )")
692 >            End If
693  
694 <        ' si ça ne touche pas à la face
695 <        If Not Distance(Me.SwFace, inter.x, inter.y, inter.z) < Epsilon Then
696 <            AjouterMiniPoutresSurFaceInterne(inter.lst_sPoutre.Item(1), face, inter.x, inter.y, inter.z)
697 <            'MsgBox("On ajoute une mini-poutre entre la poutre " & inter.lst_sPoutre.Item(1).nom & vbCr & " et le point ( " & Format(inter.x * 1000, "0000") & " , " & Format(inter.y * 1000, "0000") & " , " & Format(inter.y * 1000, "0000") & " )")
694 >        Else ' flagger la seule face comme face interne
695 >            Me.MettreAttributFaceInterne(Me.SwFace, 2 * Me.Aire / Me.Perimetre, True)
696 >            If Not Distance(Me.SwFace, inter.x, inter.y, inter.z) < Epsilon Then
697 >                AjouterMiniPoutresSurFaceInterne(inter.lst_sPoutre.Item(1), Me.SwFace, inter.x, inter.y, inter.z)
698 >                'MsgBox("On ajoute une mini-poutre entre la poutre " & inter.lst_sPoutre.Item(1).nom & vbCr & " et le point ( " & Format(inter.x * 1000, "0000") & " , " & Format(inter.y * 1000, "0000") & " , " & Format(inter.y * 1000, "0000") & " )")
699 >            End If
700          End If
1227
701          swModel.SetInferenceMode(True)
702  
703      End Sub
704  
705  
706      Friend Overridable Sub chercherAttributs()
707 <        Dim swEnt As SldWorks.Entity
708 <        Dim attr As SldWorks.Attribute
707 >        Dim swEnt As sldworks.Entity
708 >        Dim attr As sldworks.Attribute
709  
710          swEnt = Me.SwFace
711  
# Line 1243 | Line 716 | Public Class SuperFace
716  
717      End Sub
718  
719 <    Private Function Flipper(ByRef PlanDessus As SldWorks.RefPlane, ByRef inter As InterPoutreVolume) As Boolean
719 >    Protected Function Flipper(ByRef PlanDessus As sldworks.RefPlane, ByRef inter As InterAreteFace) As Boolean
720          ' function qui dit si l'on doit flipper le sens du plan de référence.
721          ' calcul de la direction à prendre
722          Dim retval As Object
# Line 1251 | Line 724 | Public Class SuperFace
724          Dim ret2(6) As Double
725          Dim normalePlan(2) As Double
726          Dim OV(2) As Double
727 <        Dim swSurf As SldWorks.Surface
727 >        Dim swSurf As sldworks.Surface
728  
729          retval = PlanDessus.GetRefPlaneParams()
730          ret = retval
731          normalePlan(0) = ret(6) : normalePlan(1) = ret(7) : normalePlan(2) = ret(8)
732 <        swSurf = Me.lst_Faces.Item(1).GetSurface
732 >        swSurf = Me.lst_Faces.Item(0).GetSurface
733          retval = swSurf.CylinderParams() ' 7 doubles, les 3 premiers sont l'origine
734          ret2 = retval
735          OV(0) = ret2(0) - inter.x : OV(1) = ret2(1) - inter.y : OV(2) = ret2(2) - inter.z
# Line 1267 | Line 740 | Public Class SuperFace
740  
741      End Function
742  
743 <
744 <    Private Function DessineSectionPoutre(ByRef Poutre As SlyAretePoutre, ByVal TranslationX As Double, ByVal TranslationY As Double, ByVal numero As Integer, ByRef swSketch As SldWorks.Sketch, ByRef inter As InterPoutreVolume, ByRef MettreFI As Boolean) As Double()
743 >    ''' <summary>
744 >    ''' Sub qui dessine (insère des lignes) sur le sketch en fonction de la forme de la poutre.
745 >    ''' </summary>
746 >    ''' <param name="Poutre"></param>
747 >    ''' <param name="TranslationX"></param>
748 >    ''' <param name="TranslationY"></param>
749 >    ''' <param name="numero"></param>
750 >    ''' <param name="swSketch"></param>
751 >    ''' <param name="inter"></param>
752 >    ''' <param name="MettreFI"></param>
753 >    ''' <returns></returns>
754 >    ''' <remarks>Si Flag = 2 alors on met une faceInterne ET une mini-poutre</remarks>
755 >    Protected Function DessineSectionPoutre(ByRef Poutre As SlyAretePoutre, ByVal TranslationX As Double, ByVal TranslationY As Double, ByVal numero As Integer, ByRef swSketch As sldworks.Sketch, ByRef inter As InterAreteFace, ByRef MettreFI As Boolean, ByRef autreSection As Boolean, ByRef AjouterMiniPoutre As Boolean) As Double()
756          ' le sketch est déjà inséré, il faut juste mettre des swmodel.line ou autre
757          ' doit retourner r() qui est un point situé à l'intérieur de la coupe
758 <        Dim sketchline As SldWorks.SketchSegment
758 >        Dim sketchline As sldworks.SketchSegment
759          Dim longueur As Double
760          Dim r(2) As Double
761          Dim sk(1) As Double
# Line 1322 | Line 806 | Public Class SuperFace
806                      r(1) = inter.y + 5000 * Epsilon * IP(1)
807                      r(2) = inter.z + 5000 * Epsilon * IP(2)
808  
809 +                    autreSection = True
810 +                    AjouterMiniPoutre = False
811 +                    MettreFI = True
812 +
813                  Case 2
814                      ReDim Ligne(19)
815  
# Line 1355 | Line 843 | Public Class SuperFace
843                      r(1) = inter.y - 5000 * Epsilon * IP(1)
844                      r(2) = inter.z - 5000 * Epsilon * IP(2)
845  
846 +                    autreSection = False
847 +                    AjouterMiniPoutre = False
848 +                    MettreFI = True
849              End Select
850 <            MettreFI = True
850 >
851 >
852          ElseIf Left(Nomsection, 2) = "ST" Or Nomsection = " Tube carré générique" Then ' tube carré troué
853              Dim P(3, 1) As Double
854              Select Case numero
# Line 1370 | Line 862 | Public Class SuperFace
862                      P(3, 0) = P(2, 0)
863                      P(3, 1) = P(0, 1)
864  
865 <                    r(0) = P(0, 0) - 1000 * Epsilon
865 >                    r(0) = Poutre.GetD1 / 2 - Poutre.GetD3 / 2
866                      r(1) = 0 : r(2) = 0
867                      Outils_Math.Rotation2D(pt3, r(0), r(1))
868                      r(0) += TranslationX
# Line 1392 | Line 884 | Public Class SuperFace
884                      Ligne(8) = P(2, 0) : Ligne(9) = P(2, 1) : Ligne(10) = P(3, 0) : Ligne(11) = P(3, 1)
885                      Ligne(12) = P(3, 0) : Ligne(13) = P(3, 1) : Ligne(14) = P(0, 0) : Ligne(15) = P(0, 1)
886                      MettreFI = False
887 +                    autreSection = True
888 +                    AjouterMiniPoutre = False
889  
890                  Case 2
891                      P(0, 0) = Poutre.GetD1 / 2 - Poutre.GetD3
# Line 1403 | Line 897 | Public Class SuperFace
897                      P(3, 0) = P(2, 0)
898                      P(3, 1) = P(0, 1)
899  
900 <                    r(0) = P(0, 0) + 1000 * Epsilon
900 >                    r(0) = Poutre.GetD1 / 2 - Poutre.GetD3 / 2
901                      r(1) = 0 : r(2) = 0
902                      Outils_Math.Rotation2D(pt3, r(0), r(1))
903                      r(0) += TranslationX
# Line 1426 | Line 920 | Public Class SuperFace
920                      Ligne(12) = P(3, 0) : Ligne(13) = P(3, 1) : Ligne(14) = P(0, 0) : Ligne(15) = P(0, 1)
921  
922                      MettreFI = True  ' lorsque l'on sort on met une face interne
923 +                    autreSection = False
924 +                    AjouterMiniPoutre = True
925  
926              End Select
927  
# Line 1474 | Line 970 | Public Class SuperFace
970                      r(0) = inter.x + 5000 * Epsilon * IP(0)
971                      r(1) = inter.y + 5000 * Epsilon * IP(1)
972                      r(2) = inter.z + 5000 * Epsilon * IP(2)
973 +                    autreSection = True
974 +                    AjouterMiniPoutre = False
975 +                    MettreFI = True
976                  Case 2
977  
978                      Dim d As Double
# Line 1517 | Line 1016 | Public Class SuperFace
1016                      r(0) = inter.x - 5000 * Epsilon * IP(0)
1017                      r(1) = inter.y - 5000 * Epsilon * IP(1)
1018                      r(2) = inter.z - 5000 * Epsilon * IP(2)
1019 <
1019 >                    autreSection = False
1020 >                    AjouterMiniPoutre = False
1021 >                    MettreFI = True
1022              End Select
1023              MettreFI = True
1024  
1025 <        ElseIf Left(Nomsection, 4) = "Tube" Or Nomsection = " Tuyau (Pipe) générique" Then ' le tube rond
1025 >        ElseIf Left(Nomsection, 5) = "Tuyau" OrElse Nomsection = " Tuyau (Pipe) générique" Then ' le tube rond
1026              Dim p(4, 1) As Double
1027              p(0, 0) = Poutre.GetD1 / 2 - Poutre.GetD3
1028              p(0, 1) = 0
# Line 1559 | Line 1060 | Public Class SuperFace
1060                      swModel.CreateArc2(p(4, 0), p(4, 1), 0, p(1, 0), p(1, 1), 0, p(3, 0), p(3, 1), 0, 1)
1061                      swModel.CreateArc2(p(4, 0), p(4, 1), 0, p(0, 0), p(0, 1), 0, p(2, 0), p(2, 1), 0, 1)
1062                      MettreFI = True
1063 <                    'Flag = 2
1063 >                    autreSection = True
1064 >                    AjouterMiniPoutre = False
1065 >
1066                  Case 2
1067  
1068                      r(0) = 0
# Line 1584 | Line 1087 | Public Class SuperFace
1087                      swModel.CreateArc2(p(4, 0), p(4, 1), 0, p(1, 0), p(1, 1), 0, p(3, 0), p(3, 1), 0, -1)
1088                      swModel.CreateArc2(p(4, 0), p(4, 1), 0, p(0, 0), p(0, 1), 0, p(2, 0), p(2, 1), 0, -1)
1089                      'MettreFI = True  ' lorsque l'on sort on met une face interne
1090 <                    MettreFI = False
1091 <                    Me.Flag = 2
1092 <                    'Case 1 ' le cercle extérieur
1590 <                    '    swModel.CreateCircleByRadius2(TranslationX, TranslationY, 0, Poutre.GetD1 / 2)
1591 <                    '    MettreFI = False
1592 <                    '    r(0) = 0 : r(1) = 0 : r(2) = 0
1593 <                    '    r = Commun.TransfertSketchToModel(swSketch, r)
1594 <                    'Case 2
1595 <                    '    swModel.CreateCircleByRadius2(TranslationX, TranslationY, 0, (Poutre.GetD1 / 2) - Poutre.GetD3)
1596 <                    '    r(0) = (Poutre.GetD1 / 2 - (Poutre.GetD3 / 2))
1597 <                    '    r(1) = 0 : r(2) = 0
1598 <                    '    r = Commun.TransfertSketchToModel(swSketch, r)
1599 <                    '    MettreFI = True
1600 <            End Select
1090 >                    MettreFI = true
1091 >                    autreSection = False
1092 >                    AjouterMiniPoutre = True
1093  
1094 <        ElseIf Left(Nomsection, 1) = "C" Or Nomsection = " Poutre en C générique" Then ' le channel
1603 <            Dim P(7, 1) As Double
1094 >            End Select
1095  
1096 <            Select Case numero
1097 <                Case 1 ' le C au complet
1096 >        ElseIf Left(Poutre.GetNomSection, 2) = "Cy" Or Nomsection = " Cylindrique (Rod) générique" Then ' Pipe,
1097 >            Dim P(2, 1) As Double
1098 >            Dim d As Double, e As Double
1099 >            d = Poutre.GetD1 / 4 ' Math.Sin(30)  ( et on doit diviser le diamètre par 2)
1100 >            e = Poutre.GetD1 * Math.Sqrt(3) / 4 ' cos (30°)
1101  
1102 <                    P(0, 0) = Poutre.GetD1 / 2 - Poutre.GetD3
1103 <                    P(0, 1) = Poutre.GetD5
1104 <                    P(1, 0) = P(0, 0)
1105 <                    P(1, 1) = Poutre.GetD5 + Poutre.GetD4 - Poutre.GetD2
1106 <                    P(2, 0) = Poutre.GetD1 / 2
1107 <                    P(2, 1) = P(1, 1)
1614 <                    P(3, 0) = P(2, 0)
1615 <                    P(3, 1) = P(1, 1) + Poutre.GetD2
1616 <                    P(4, 0) = -P(3, 0)
1617 <                    P(4, 1) = P(3, 1)
1618 <                    P(5, 0) = P(4, 0)
1619 <                    P(5, 1) = P(1, 1)
1620 <                    P(6, 0) = -P(1, 0)
1621 <                    P(6, 1) = P(5, 1)
1622 <                    P(7, 0) = -P(0, 0)
1623 <                    P(7, 1) = P(0, 1)
1102 >            P(0, 0) = 0
1103 >            P(0, 1) = 0
1104 >            P(1, 0) = d
1105 >            P(1, 1) = -e
1106 >            P(2, 0) = d
1107 >            P(2, 1) = e
1108  
1109 +            Select Case numero
1110 +                Case 1
1111                      r(0) = P(0, 0) + 1000 * Epsilon
1112                      r(1) = 0 : r(2) = 0
1113                      Outils_Math.Rotation2D(pt3, r(0), r(1))
1114                      r(0) += TranslationX
1115                      r(1) += TranslationY
1116                      r = Commun.TransfertSketchToModel(swSketch, r)
1631
1117                      pt3(0) -= TranslationX
1118                      pt3(1) -= TranslationY
1119                      pt3(0) /= longueur : pt3(1) /= longueur
1120 <                    For i = 0 To 7
1120 >                    For i = 0 To 2
1121                          Outils_Math.Rotation2D(pt3, P(i, 0), P(i, 1))
1122                          P(i, 0) += TranslationX
1123                          P(i, 1) += TranslationY
1124                      Next i
1125 <
1126 <                    ReDim Ligne(35)
1127 <                    For i = 0 To 6
1128 <                        Ligne(i * 4) = P(i, 0) : Ligne(i * 4 + 1) = P(i, 1) : Ligne(i * 4 + 2) = P(i + 1, 0) : Ligne(i * 4 + 3) = P(i + 1, 1)
1129 <                    Next i
1130 <                    Ligne(28) = P(7, 0) : Ligne(29) = P(7, 1) : Ligne(30) = P(0, 0) : Ligne(31) = P(0, 1)
1131 <
1647 <                    MettreFI = False
1648 <                    Me.Flag = 2
1125 >                    ReDim Ligne(7)
1126 >                    Ligne(0) = P(0, 0) : Ligne(1) = P(0, 1) : Ligne(2) = P(1, 0) : Ligne(3) = P(1, 1)
1127 >                    Ligne(4) = P(0, 0) : Ligne(5) = P(0, 1) : Ligne(6) = P(2, 0) : Ligne(7) = P(2, 1)
1128 >                    swModel.CreateArc2(P(0, 0), P(0, 1), 0, P(1, 0), P(1, 1), 0, P(2, 0), P(2, 1), 0, 1) ' le dernier param est la direction.  1 ou -1
1129 >                    autreSection = True
1130 >                    AjouterMiniPoutre = False
1131 >                    MettreFI = True
1132                  Case 2
1133 <                    MettreFI = False ' Attention, peut planter à cause de ça.
1651 <            End Select
1652 <
1653 <        ElseIf Left(Nomsection, 1) = "L" Or Nomsection = " Poutre en L générique" Then ' l'Angle en L
1654 <            Dim P(5, 1) As Double
1655 <
1656 <            Select Case numero
1657 <                Case 1 ' le C au complet
1658 <
1659 <                    P(0, 0) = -Poutre.GetD5 + Poutre.GetD1
1660 <                    P(0, 1) = -Poutre.GetD6 + Poutre.GetD4
1661 <                    P(1, 0) = -Poutre.GetD5 + Poutre.GetD3
1662 <                    P(1, 1) = P(0, 1)
1663 <                    P(2, 0) = P(1, 0)
1664 <                    P(2, 1) = -Poutre.GetD6 + Poutre.GetD2
1665 <                    P(3, 0) = -Poutre.GetD5
1666 <                    P(3, 1) = P(2, 1)
1667 <                    P(4, 0) = P(3, 0)
1668 <                    P(4, 1) = -Poutre.GetD6
1669 <                    P(5, 0) = P(0, 0)
1670 <                    P(5, 1) = P(4, 1)
1671 <
1672 <                    r(0) = P(1, 0) - 1000 * Epsilon
1133 >                    r(0) = P(0, 0) - 1000 * Epsilon
1134                      r(1) = 0 : r(2) = 0
1135                      Outils_Math.Rotation2D(pt3, r(0), r(1))
1136                      r(0) += TranslationX
# Line 1679 | Line 1140 | Public Class SuperFace
1140                      pt3(0) -= TranslationX
1141                      pt3(1) -= TranslationY
1142                      pt3(0) /= longueur : pt3(1) /= longueur
1143 <                    For i = 0 To 5
1143 >                    For i = 0 To 2
1144                          Outils_Math.Rotation2D(pt3, P(i, 0), P(i, 1))
1145                          P(i, 0) += TranslationX
1146                          P(i, 1) += TranslationY
1147                      Next i
1148 +                    ReDim Ligne(7)
1149 +                    Ligne(0) = P(0, 0) : Ligne(1) = P(0, 1) : Ligne(2) = P(1, 0) : Ligne(3) = P(1, 1)
1150 +                    Ligne(4) = P(0, 0) : Ligne(5) = P(0, 1) : Ligne(6) = P(2, 0) : Ligne(7) = P(2, 1)
1151  
1152 <                    ReDim Ligne(35)
1153 <                    For i = 0 To 4
1154 <                        Ligne(i * 4) = P(i, 0) : Ligne(i * 4 + 1) = P(i, 1) : Ligne(i * 4 + 2) = P(i + 1, 0) : Ligne(i * 4 + 3) = P(i + 1, 1)
1155 <                    Next i
1692 <                    Ligne(20) = P(5, 0) : Ligne(21) = P(5, 1) : Ligne(22) = P(0, 0) : Ligne(23) = P(0, 1)
1693 <
1694 <                    MettreFI = False  ' lorsque l'on sort on met une face interne
1695 <                    Me.Flag = 2
1696 <                Case 2
1697 <                    MettreFI = False ' Attention, peut planter à cause de ça.
1152 >                    swModel.CreateArc2(P(0, 0), P(0, 1), 0, P(1, 0), P(1, 1), 0, P(2, 0), P(2, 1), 0, -1) ' le dernier param est la direction.  1 ou -1
1153 >                    autreSection = False
1154 >                    AjouterMiniPoutre = False
1155 >                    MettreFI = True
1156              End Select
1157 +            MettreFI = True
1158 +
1159 +
1160 +        ElseIf Left(Nomsection, 1) = "C" Or Nomsection = " Poutre en C générique" Then ' le channel
1161 +            Dim P(7, 1) As Double
1162  
1163 +            P(0, 0) = Poutre.GetD1 / 2 - Poutre.GetD3
1164 +            P(0, 1) = Poutre.GetD5
1165 +            P(1, 0) = P(0, 0)
1166 +            P(1, 1) = Poutre.GetD5 + Poutre.GetD4 - Poutre.GetD2
1167 +            P(2, 0) = Poutre.GetD1 / 2
1168 +            P(2, 1) = P(1, 1)
1169 +            P(3, 0) = P(2, 0)
1170 +            P(3, 1) = P(1, 1) + Poutre.GetD2
1171 +            P(4, 0) = -P(3, 0)
1172 +            P(4, 1) = P(3, 1)
1173 +            P(5, 0) = P(4, 0)
1174 +            P(5, 1) = P(1, 1)
1175 +            P(6, 0) = -P(1, 0)
1176 +            P(6, 1) = P(5, 1)
1177 +            P(7, 0) = -P(0, 0)
1178 +            P(7, 1) = P(0, 1)
1179 +
1180 +            r(0) = P(0, 0) + 1000 * Epsilon
1181 +            r(1) = P(0, 1) : r(2) = 0
1182 +            Outils_Math.Rotation2D(pt3, r(0), r(1))
1183 +            r(0) += TranslationX
1184 +            r(1) += TranslationY
1185 +            r = Commun.TransfertSketchToModel(swSketch, r)
1186 +
1187 +            pt3(0) -= TranslationX
1188 +            pt3(1) -= TranslationY
1189 +            pt3(0) /= longueur : pt3(1) /= longueur
1190 +            For i = 0 To 7
1191 +                Outils_Math.Rotation2D(pt3, P(i, 0), P(i, 1))
1192 +                P(i, 0) += TranslationX
1193 +                P(i, 1) += TranslationY
1194 +            Next i
1195 +
1196 +            ReDim Ligne(35)
1197 +            For i = 0 To 6
1198 +                Ligne(i * 4) = P(i, 0) : Ligne(i * 4 + 1) = P(i, 1) : Ligne(i * 4 + 2) = P(i + 1, 0) : Ligne(i * 4 + 3) = P(i + 1, 1)
1199 +            Next i
1200 +            Ligne(28) = P(7, 0) : Ligne(29) = P(7, 1) : Ligne(30) = P(0, 0) : Ligne(31) = P(0, 1)
1201 +
1202 +            MettreFI = True
1203 +            autreSection = False
1204 +            AjouterMiniPoutre = True
1205 +
1206 +
1207 +        ElseIf Left(Nomsection, 1) = "L" Or Nomsection = " Poutre en L générique" Then ' l'Angle en L
1208 +            Dim P(5, 1) As Double
1209 +
1210 +            P(0, 0) = -Poutre.GetD5 + Poutre.GetD1
1211 +            P(0, 1) = -Poutre.GetD6 + Poutre.GetD4
1212 +            P(1, 0) = -Poutre.GetD5 + Poutre.GetD3
1213 +            P(1, 1) = P(0, 1)
1214 +            P(2, 0) = P(1, 0)
1215 +            P(2, 1) = -Poutre.GetD6 + Poutre.GetD2
1216 +            P(3, 0) = -Poutre.GetD5
1217 +            P(3, 1) = P(2, 1)
1218 +            P(4, 0) = P(3, 0)
1219 +            P(4, 1) = -Poutre.GetD6
1220 +            P(5, 0) = P(0, 0)
1221 +            P(5, 1) = P(4, 1)
1222 +
1223 +            r(0) = P(1, 0) - 1000 * Epsilon
1224 +            r(1) = 0 : r(2) = 0
1225 +            Outils_Math.Rotation2D(pt3, r(0), r(1))
1226 +            r(0) += TranslationX
1227 +            r(1) += TranslationY
1228 +            r = Commun.TransfertSketchToModel(swSketch, r)
1229 +
1230 +            pt3(0) -= TranslationX
1231 +            pt3(1) -= TranslationY
1232 +            pt3(0) /= longueur : pt3(1) /= longueur
1233 +            For i = 0 To 5
1234 +                Outils_Math.Rotation2D(pt3, P(i, 0), P(i, 1))
1235 +                P(i, 0) += TranslationX
1236 +                P(i, 1) += TranslationY
1237 +            Next i
1238 +
1239 +            ReDim Ligne(35)
1240 +            For i = 0 To 4
1241 +                Ligne(i * 4) = P(i, 0) : Ligne(i * 4 + 1) = P(i, 1) : Ligne(i * 4 + 2) = P(i + 1, 0) : Ligne(i * 4 + 3) = P(i + 1, 1)
1242 +            Next i
1243 +            Ligne(20) = P(5, 0) : Ligne(21) = P(5, 1) : Ligne(22) = P(0, 0) : Ligne(23) = P(0, 1)
1244 +
1245 +            autreSection = False
1246 +            AjouterMiniPoutre = True
1247 +            MettreFI = True
1248  
1249          ElseIf Left(Nomsection, 1) = "T" Or Nomsection = " Poutre en T générique" Then ' le T
1250              Select Case numero
# Line 1708 | Line 1256 | Public Class SuperFace
1256  
1257                      P(0, 0) = 0
1258                      P(0, 1) = 0
1259 <                    P(1, 0) = -d
1259 >                    P(1, 0) = d
1260                      P(1, 1) = -Poutre.GetD4 / 2.0R
1261                      P(2, 0) = -(Poutre.GetD1 - Poutre.GetD5 - Poutre.GetD3)
1262                      P(2, 1) = -Poutre.GetD4 / 2.0R
# Line 1725 | Line 1273 | Public Class SuperFace
1273                      P(8, 0) = P(1, 0)
1274                      P(8, 1) = -P(1, 1)
1275  
1276 <                    r(0) = P(0, 0) + 1000 * Epsilon
1276 >                    r(0) = P(0, 0) - 1000 * Epsilon
1277                      r(1) = 0 : r(2) = 0
1278                      Outils_Math.Rotation2D(pt3, r(0), r(1))
1279                      r(0) += TranslationX
# Line 1746 | Line 1294 | Public Class SuperFace
1294                          Ligne(i * 4) = P(i, 0) : Ligne(i * 4 + 1) = P(i, 1) : Ligne(i * 4 + 2) = P(i + 1, 0) : Ligne(i * 4 + 3) = P(i + 1, 1)
1295                      Next i
1296                      Ligne(32) = P(8, 0) : Ligne(33) = P(8, 1) : Ligne(34) = P(0, 0) : Ligne(35) = P(0, 1)
1297 <
1297 >                    autreSection = True
1298 >                    AjouterMiniPoutre = False
1299 >                    MettreFI = True
1300                  Case 2
1301                      Dim P(4, 1) As Double
1302                      Dim d As Double
# Line 1755 | Line 1305 | Public Class SuperFace
1305                      P(0, 0) = 0
1306                      P(0, 1) = 0
1307  
1308 <                    P(1, 0) = -d
1308 >                    P(1, 0) = d
1309                      P(1, 1) = -Poutre.GetD4 / 2.0R
1310                      P(2, 0) = Poutre.GetD5
1311                      P(2, 1) = -Poutre.GetD4 / 2.0R
# Line 1764 | Line 1314 | Public Class SuperFace
1314                      P(4, 0) = P(1, 0)
1315                      P(4, 1) = P(3, 1)
1316  
1317 <                    r(0) = P(0, 0) - 1000 * Epsilon
1317 >                    r(0) = P(0, 0) + 1000 * Epsilon
1318                      r(1) = 0 : r(2) = 0
1319                      Outils_Math.Rotation2D(pt3, r(0), r(1))
1320                      r(0) += TranslationX
# Line 1785 | Line 1335 | Public Class SuperFace
1335                          Ligne(i * 4) = P(i, 0) : Ligne(i * 4 + 1) = P(i, 1) : Ligne(i * 4 + 2) = P(i + 1, 0) : Ligne(i * 4 + 3) = P(i + 1, 1)
1336                      Next i
1337                      Ligne(16) = P(4, 0) : Ligne(17) = P(4, 1) : Ligne(18) = P(0, 0) : Ligne(19) = P(0, 1)
1338 +                    autreSection = False
1339 +                    AjouterMiniPoutre = False
1340 +                    MettreFI = True
1341 +            End Select
1342 +  
1343 +
1344 +        Else
1345 +            MsgBox("Section de poutre non reconnu!", MsgBoxStyle.Critical, "Commun.DessineSectionPoutre")
1346 +        End If
1347 +
1348 +
1349 +        If Not Ligne Is Nothing Then
1350 +            For i = 0 To UBound(Ligne) Step 4
1351 +                sketchline = swModel.CreateLine2(Ligne(i), Ligne(i + 1), 0, Ligne(i + 2), Ligne(i + 3), 0)
1352 +            Next i
1353 +        End If
1354 +
1355 +        Return r
1356 +
1357 +    End Function
1358 +
1359 +
1360 +
1361 +
1362 +    ''' <summary>
1363 +    ''' Sub qui dessine (insère des lignes) sur le sketch en fonction de la forme de la poutre.
1364 +    ''' </summary>
1365 +    ''' <param name="Poutre"></param>
1366 +    ''' <param name="TranslationX"></param>
1367 +    ''' <param name="TranslationY"></param>
1368 +    ''' <param name="numero">Si on doit découper (pipe et cercle) alors le # nous donne le numéro de l'ittération </param>
1369 +    ''' <param name="swSketch"></param>
1370 +    ''' <param name="inter"></param>
1371 +    ''' <param name="MettreFI"></param>
1372 +    ''' <returns></returns>
1373 +    ''' <remarks>C'est la version simple, donc une seule face nécessaire</remarks>
1374 +    Protected Function DessineSectionPoutreSimple(ByRef Poutre As SlyAretePoutre, ByVal TranslationX As Double, ByVal TranslationY As Double, ByVal numero As Integer, ByRef swSketch As sldworks.Sketch, ByRef inter As InterAreteFace, ByRef MettreFI As Boolean, ByRef AutreSection As Boolean, ByRef AjouterMiniPoutre As Boolean) As Double()
1375 +        ' le sketch est déjà inséré, il faut juste mettre des swmodel.line ou autre
1376 +        ' doit retourner r() qui est un point situé à l'intérieur de la coupe
1377 +        Dim sketchline As sldworks.SketchSegment
1378 +        Dim longueur As Double
1379 +        Dim r(2) As Double
1380 +        Dim sk(1) As Double
1381 +        Dim i As Integer
1382 +        Dim Ligne() As Double = Nothing ' liste des lignes (4 valeurs par ligne)
1383 +        Dim pt3() As Double
1384 +        Dim Nomsection As String
1385 +
1386 +
1387 +        ' on doit activer le sketch avant d'utiliser la fonction getactivesketch
1388 +        pt3 = Poutre.GetPoint3
1389 +        longueur = Math.Sqrt(pt3(0) * pt3(0) + pt3(1) * pt3(1))
1390 +        Dim IP(2) As Double ' IP est le vecteur directionnel
1391 +        IP(0) = pt3(0) - inter.x : IP(1) = pt3(1) - inter.y : IP(2) = pt3(2) - inter.z
1392 +
1393 +
1394 +        pt3 = Commun.TransfertModelSketch(swSketch, pt3)
1395 +        longueur = Math.Sqrt(pt3(0) * pt3(0) + pt3(1) * pt3(1))
1396 +
1397 +        Nomsection = Poutre.GetNomSection
1398 +        If Nomsection = "Rectangle" Or Nomsection = " Rectangle générique" Then ' un rectangle
1399 +            Dim P(3, 1) As Double
1400 +            P(0, 0) = Poutre.GetD1 / 2
1401 +            P(0, 1) = Poutre.GetD2 / 2
1402 +            P(1, 0) = -Poutre.GetD1 / 2
1403 +            P(1, 1) = Poutre.GetD2 / 2
1404 +            P(2, 0) = -Poutre.GetD1 / 2
1405 +            P(2, 1) = -Poutre.GetD2 / 2
1406 +            P(3, 0) = Poutre.GetD1 / 2
1407 +            P(3, 1) = -Poutre.GetD2 / 2
1408 +
1409 +            ReDim Ligne(15)
1410 +            pt3(0) -= TranslationX
1411 +            pt3(1) -= TranslationY
1412 +            For i = 0 To 3
1413 +                Outils_Math.Rotation2D(pt3, P(i, 0), P(i, 1))
1414 +                P(i, 0) += TranslationX
1415 +                P(i, 1) += TranslationY
1416 +            Next i
1417 +
1418 +            For i = 0 To 2
1419 +                Ligne(i * 4) = P(i, 0) : Ligne(i * 4 + 1) = P(i, 1) : Ligne(i * 4 + 2) = P(i + 1, 0) : Ligne(i * 4 + 3) = P(i + 1, 1)
1420 +            Next i
1421 +            Ligne(12) = P(3, 0) : Ligne(13) = P(3, 1) : Ligne(14) = P(0, 0) : Ligne(15) = P(0, 1)
1422 +
1423 +            r(0) = inter.x + 5000 * Epsilon * IP(0)
1424 +            r(1) = inter.y + 5000 * Epsilon * IP(1)
1425 +            r(2) = inter.z + 5000 * Epsilon * IP(2)
1426 +
1427 +            AutreSection = False
1428 +            AjouterMiniPoutre = True
1429 +            MettreFI = True
1430 +
1431 +
1432 +        ElseIf Left(Nomsection, 2) = "ST" Or Nomsection = " Tube carré générique" Then ' tube carré troué
1433 +            Dim P(3, 1) As Double
1434 +            Select Case numero
1435 +                Case 1
1436 +                    P(0, 0) = Poutre.GetD1 / 2
1437 +                    P(0, 1) = -Poutre.GetD2 / 2
1438 +                    P(1, 0) = P(0, 0)
1439 +                    P(1, 1) = -P(0, 1)
1440 +                    P(2, 0) = -P(0, 0)
1441 +                    P(2, 1) = P(1, 1)
1442 +                    P(3, 0) = P(2, 0)
1443 +                    P(3, 1) = P(0, 1)
1444 +
1445 +                    r(0) = P(0, 0) - 1000 * Epsilon
1446 +                    r(1) = 0 : r(2) = 0
1447 +                    Outils_Math.Rotation2D(pt3, r(0), r(1))
1448 +                    r(0) += TranslationX
1449 +                    r(1) += TranslationY
1450 +                    r = Commun.TransfertSketchToModel(swSketch, r)
1451 +
1452 +                    pt3(0) -= TranslationX
1453 +                    pt3(1) -= TranslationY
1454 +                    pt3(0) /= longueur : pt3(1) /= longueur
1455 +                    For i = 0 To 3
1456 +                        Outils_Math.Rotation2D(pt3, P(i, 0), P(i, 1))
1457 +                        P(i, 0) += TranslationX
1458 +                        P(i, 1) += TranslationY
1459 +                    Next i
1460 +
1461 +                    ReDim Ligne(15)
1462 +                    Ligne(0) = P(0, 0) : Ligne(1) = P(0, 1) : Ligne(2) = P(1, 0) : Ligne(3) = P(1, 1)
1463 +                    Ligne(4) = P(1, 0) : Ligne(5) = P(1, 1) : Ligne(6) = P(2, 0) : Ligne(7) = P(2, 1)
1464 +                    Ligne(8) = P(2, 0) : Ligne(9) = P(2, 1) : Ligne(10) = P(3, 0) : Ligne(11) = P(3, 1)
1465 +                    Ligne(12) = P(3, 0) : Ligne(13) = P(3, 1) : Ligne(14) = P(0, 0) : Ligne(15) = P(0, 1)
1466 +                    MettreFI = False
1467 +                    AutreSection = True
1468 +                    AjouterMiniPoutre = False
1469 +
1470 +                Case 2
1471 +                    P(0, 0) = Poutre.GetD1 / 2 - Poutre.GetD3
1472 +                    P(0, 1) = -Poutre.GetD2 / 2 + Poutre.GetD3
1473 +                    P(1, 0) = P(0, 0)
1474 +                    P(1, 1) = -P(0, 1)
1475 +                    P(2, 0) = -P(1, 0)
1476 +                    P(2, 1) = P(1, 1)
1477 +                    P(3, 0) = P(2, 0)
1478 +                    P(3, 1) = P(0, 1)
1479 +
1480 +                    r(0) = P(0, 0) + 1000 * Epsilon
1481 +                    r(1) = 0 : r(2) = 0
1482 +                    Outils_Math.Rotation2D(pt3, r(0), r(1))
1483 +                    r(0) += TranslationX
1484 +                    r(1) += TranslationY
1485 +                    r = Commun.TransfertSketchToModel(swSketch, r)
1486 +
1487 +                    pt3(0) -= TranslationX
1488 +                    pt3(1) -= TranslationY
1489 +                    pt3(0) /= longueur : pt3(1) /= longueur
1490 +                    For i = 0 To 3
1491 +                        Outils_Math.Rotation2D(pt3, P(i, 0), P(i, 1))
1492 +                        P(i, 0) += TranslationX
1493 +                        P(i, 1) += TranslationY
1494 +                    Next i
1495 +
1496 +                    ReDim Ligne(15)
1497 +                    Ligne(0) = P(0, 0) : Ligne(1) = P(0, 1) : Ligne(2) = P(1, 0) : Ligne(3) = P(1, 1)
1498 +                    Ligne(4) = P(1, 0) : Ligne(5) = P(1, 1) : Ligne(6) = P(2, 0) : Ligne(7) = P(2, 1)
1499 +                    Ligne(8) = P(2, 0) : Ligne(9) = P(2, 1) : Ligne(10) = P(3, 0) : Ligne(11) = P(3, 1)
1500 +                    Ligne(12) = P(3, 0) : Ligne(13) = P(3, 1) : Ligne(14) = P(0, 0) : Ligne(15) = P(0, 1)
1501 +
1502 +                    MettreFI = True  ' lorsque l'on sort on met une face interne
1503 +                    AutreSection = False
1504 +                    AjouterMiniPoutre = False
1505  
1506              End Select
1507 +
1508 +        ElseIf Left(Nomsection, 1) = "S" Or Nomsection = " Poutre en I générique" Then ' poutre en I de type S
1509 +            Dim P(11, 1) As Double
1510 +            Dim d As Double
1511 +
1512 +            d = Poutre.GetD4 * 0.8660254038 '  section.D4 / (2 * tan(30))
1513 +
1514 +            P(0, 0) = (Poutre.GetD1 / 2) - Poutre.GetD3
1515 +            P(0, 1) = -Poutre.GetD4 / 2
1516 +            P(1, 0) = P(0, 0)
1517 +            P(1, 1) = -Poutre.GetD2 / 2
1518 +            P(2, 0) = Poutre.GetD1 / 2
1519 +            P(2, 1) = P(1, 1)
1520 +            P(3, 0) = P(2, 0)
1521 +            P(3, 1) = -P(2, 1)
1522 +            P(4, 0) = P(1, 0)
1523 +            P(4, 1) = -P(1, 1)
1524 +            P(5, 0) = P(0, 0)
1525 +            P(5, 1) = -P(0, 1)
1526 +
1527 +            P(6, 0) = -((Poutre.GetD1 / 2) - Poutre.GetD3)
1528 +            P(6, 1) = Poutre.GetD4 / 2.0R
1529 +            P(7, 0) = P(6, 0)
1530 +            P(7, 1) = Poutre.GetD2 / 2
1531 +            P(8, 0) = -Poutre.GetD1 / 2
1532 +            P(8, 1) = P(7, 1)
1533 +            P(9, 0) = P(8, 0)
1534 +            P(9, 1) = -P(8, 1)
1535 +            P(10, 0) = P(7, 0)
1536 +            P(10, 1) = P(9, 1)
1537 +            P(11, 0) = P(6, 0)
1538 +            P(11, 1) = P(0, 1)
1539 +
1540 +
1541 +            pt3(0) -= TranslationX
1542 +            pt3(1) -= TranslationY
1543 +            pt3(0) /= longueur : pt3(1) /= longueur
1544 +            For i = 0 To 11
1545 +                Outils_Math.Rotation2D(pt3, P(i, 0), P(i, 1))
1546 +                P(i, 0) += TranslationX
1547 +                P(i, 1) += TranslationY
1548 +            Next i
1549 +
1550 +            ReDim Ligne(47)
1551 +
1552 +            For k As Integer = 0 To 10
1553 +                Ligne(4 * k + 0) = P(k, 0) : Ligne(4 * k + 1) = P(k, 1) : Ligne(4 * k + 2) = P(k + 1, 0) : Ligne(4 * k + 3) = P(k + 1, 1)
1554 +            Next k
1555 +            Ligne(44) = P(0, 0) : Ligne(45) = P(0, 1) : Ligne(46) = P(11, 0) : Ligne(47) = P(11, 1)
1556 +
1557 +
1558 +            r(0) = inter.x '+ 5000 * Epsilon * IP(0)
1559 +            r(1) = inter.y '+ 5000 * Epsilon * IP(1)
1560 +            r(2) = inter.z '+ 5000 * Epsilon * IP(2)
1561 +
1562 +            AutreSection = False
1563              MettreFI = True
1564 +            AjouterMiniPoutre = True
1565 +
1566 +
1567 +        ElseIf Left(Nomsection, 5) = "Tuyau" OrElse Nomsection = " Tuyau (Pipe) générique" Then ' le tube rond
1568 +            Dim p(4, 1) As Double
1569 +            p(0, 0) = Poutre.GetD1 / 2 - Poutre.GetD3
1570 +            p(0, 1) = 0
1571 +            p(1, 0) = Poutre.GetD1 / 2
1572 +            p(1, 1) = 0
1573 +            p(2, 0) = -p(0, 0)
1574 +            p(2, 1) = 0
1575 +            p(3, 0) = -p(1, 0)
1576 +            p(3, 1) = 0
1577 +            p(4, 0) = 0
1578 +            p(4, 1) = 0
1579 +
1580 +            Select Case numero
1581 +                Case 1
1582 +
1583 +                    r(0) = 0
1584 +                    r(1) = Poutre.GetD1 / 2 - Poutre.GetD3 / 2 : r(2) = 0
1585 +                    Outils_Math.Rotation2D(pt3, r(0), r(1))
1586 +                    r(0) += TranslationX
1587 +                    r(1) += TranslationY
1588 +                    r = Commun.TransfertSketchToModel(swSketch, r)
1589 +
1590 +                    pt3(0) -= TranslationX
1591 +                    pt3(1) -= TranslationY
1592 +                    pt3(0) /= longueur : pt3(1) /= longueur
1593 +                    For i = 0 To 4
1594 +                        Outils_Math.Rotation2D(pt3, p(i, 0), p(i, 1))
1595 +                        p(i, 0) += TranslationX
1596 +                        p(i, 1) += TranslationY
1597 +                    Next i
1598 +
1599 +                    ReDim Ligne(7)
1600 +                    Ligne(0) = p(0, 0) : Ligne(1) = p(0, 1) : Ligne(2) = p(1, 0) : Ligne(3) = p(1, 1)
1601 +                    Ligne(4) = p(2, 0) : Ligne(5) = p(2, 1) : Ligne(6) = p(3, 0) : Ligne(7) = p(3, 1)
1602 +                    swModel.CreateArc2(p(4, 0), p(4, 1), 0, p(1, 0), p(1, 1), 0, p(3, 0), p(3, 1), 0, 1)
1603 +                    swModel.CreateArc2(p(4, 0), p(4, 1), 0, p(0, 0), p(0, 1), 0, p(2, 0), p(2, 1), 0, 1)
1604 +                    MettreFI = True
1605 +                    AutreSection = True
1606 +                    AjouterMiniPoutre = False
1607 +
1608 +                Case 2
1609 +
1610 +                    r(0) = 0
1611 +                    r(1) = -Poutre.GetD1 / 2 + Poutre.GetD3 / 2 : r(2) = 0
1612 +                    Outils_Math.Rotation2D(pt3, r(0), r(1))
1613 +                    r(0) += TranslationX
1614 +                    r(1) += TranslationY
1615 +                    r = Commun.TransfertSketchToModel(swSketch, r)
1616  
1617 <        ElseIf Left(Poutre.GetNomSection, 1) = "P" Or Nomsection = " Circulaire pleine générique" Then ' Pipe,
1617 >                    pt3(0) -= TranslationX
1618 >                    pt3(1) -= TranslationY
1619 >                    pt3(0) /= longueur : pt3(1) /= longueur
1620 >                    For i = 0 To 4
1621 >                        Outils_Math.Rotation2D(pt3, p(i, 0), p(i, 1))
1622 >                        p(i, 0) += TranslationX
1623 >                        p(i, 1) += TranslationY
1624 >                    Next i
1625 >
1626 >                    ReDim Ligne(7)
1627 >                    Ligne(0) = p(0, 0) : Ligne(1) = p(0, 1) : Ligne(2) = p(1, 0) : Ligne(3) = p(1, 1)
1628 >                    Ligne(4) = p(2, 0) : Ligne(5) = p(2, 1) : Ligne(6) = p(3, 0) : Ligne(7) = p(3, 1)
1629 >                    swModel.CreateArc2(p(4, 0), p(4, 1), 0, p(1, 0), p(1, 1), 0, p(3, 0), p(3, 1), 0, -1)
1630 >                    swModel.CreateArc2(p(4, 0), p(4, 1), 0, p(0, 0), p(0, 1), 0, p(2, 0), p(2, 1), 0, -1)
1631 >                    'MettreFI = True  ' lorsque l'on sort on met une face interne
1632 >                    MettreFI = True
1633 >                    AutreSection = False
1634 >                    AjouterMiniPoutre = True
1635 >
1636 >            End Select
1637 >
1638 >        ElseIf Left(Poutre.GetNomSection, 2) = "Cy" Or Nomsection = " Cylindrique (Rod) générique" Then ' Pipe,
1639              Dim P(2, 1) As Double
1640              Dim d As Double, e As Double
1641              d = Poutre.GetD1 / 4 ' Math.Sin(30)  ( et on doit diviser le diamètre par 2)
# Line 1823 | Line 1669 | Public Class SuperFace
1669                      Ligne(4) = P(0, 0) : Ligne(5) = P(0, 1) : Ligne(6) = P(2, 0) : Ligne(7) = P(2, 1)
1670                      swModel.CreateArc2(P(0, 0), P(0, 1), 0, P(1, 0), P(1, 1), 0, P(2, 0), P(2, 1), 0, 1) ' le dernier param est la direction.  1 ou -1
1671  
1672 +
1673 +                    MettreFI = True
1674 +                    AjouterMiniPoutre = False
1675 +                    AutreSection = True
1676 +
1677                  Case 2
1678                      r(0) = P(0, 0) - 1000 * Epsilon
1679                      r(1) = 0 : r(2) = 0
# Line 1845 | Line 1696 | Public Class SuperFace
1696  
1697                      swModel.CreateArc2(P(0, 0), P(0, 1), 0, P(1, 0), P(1, 1), 0, P(2, 0), P(2, 1), 0, -1) ' le dernier param est la direction.  1 ou -1
1698  
1699 +                    MettreFI = True
1700 +                    AjouterMiniPoutre = False
1701 +                    AutreSection = False
1702 +
1703              End Select
1704 +
1705 +
1706 +
1707 +        ElseIf Left(Nomsection, 1) = "C" Or Nomsection = " Poutre en C générique" Then ' le channel
1708 +            Dim P(7, 1) As Double
1709 +
1710 +            P(0, 0) = Poutre.GetD1 / 2 - Poutre.GetD3
1711 +            P(0, 1) = Poutre.GetD5
1712 +            P(1, 0) = P(0, 0)
1713 +            P(1, 1) = Poutre.GetD5 + Poutre.GetD4 - Poutre.GetD2
1714 +            P(2, 0) = Poutre.GetD1 / 2
1715 +            P(2, 1) = P(1, 1)
1716 +            P(3, 0) = P(2, 0)
1717 +            P(3, 1) = P(1, 1) + Poutre.GetD2
1718 +            P(4, 0) = -P(3, 0)
1719 +            P(4, 1) = P(3, 1)
1720 +            P(5, 0) = P(4, 0)
1721 +            P(5, 1) = P(1, 1)
1722 +            P(6, 0) = -P(1, 0)
1723 +            P(6, 1) = P(5, 1)
1724 +            P(7, 0) = -P(0, 0)
1725 +            P(7, 1) = P(0, 1)
1726 +
1727 +            r(0) = P(0, 0) + 1000 * Epsilon
1728 +            r(1) = P(0, 1) : r(2) = 0
1729 +            Outils_Math.Rotation2D(pt3, r(0), r(1))
1730 +            r(0) += TranslationX
1731 +            r(1) += TranslationY
1732 +            r = Commun.TransfertSketchToModel(swSketch, r)
1733 +
1734 +            pt3(0) -= TranslationX
1735 +            pt3(1) -= TranslationY
1736 +            pt3(0) /= longueur : pt3(1) /= longueur
1737 +            For i = 0 To 7
1738 +                Outils_Math.Rotation2D(pt3, P(i, 0), P(i, 1))
1739 +                P(i, 0) += TranslationX
1740 +                P(i, 1) += TranslationY
1741 +            Next i
1742 +
1743 +            ReDim Ligne(35)
1744 +            For i = 0 To 6
1745 +                Ligne(i * 4) = P(i, 0) : Ligne(i * 4 + 1) = P(i, 1) : Ligne(i * 4 + 2) = P(i + 1, 0) : Ligne(i * 4 + 3) = P(i + 1, 1)
1746 +            Next i
1747 +            Ligne(28) = P(7, 0) : Ligne(29) = P(7, 1) : Ligne(30) = P(0, 0) : Ligne(31) = P(0, 1)
1748 +
1749              MettreFI = True
1750 +            AjouterMiniPoutre = True
1751 +            AutreSection = False
1752 +
1753 +
1754 +        ElseIf Left(Nomsection, 1) = "L" Or Nomsection = " Poutre en L générique" Then ' l'Angle en L
1755 +            Dim P(5, 1) As Double
1756 +
1757 +            P(0, 0) = -Poutre.GetD5 + Poutre.GetD1
1758 +            P(0, 1) = -Poutre.GetD6 + Poutre.GetD4
1759 +            P(1, 0) = -Poutre.GetD5 + Poutre.GetD3
1760 +            P(1, 1) = P(0, 1)
1761 +            P(2, 0) = P(1, 0)
1762 +            P(2, 1) = -Poutre.GetD6 + Poutre.GetD2
1763 +            P(3, 0) = -Poutre.GetD5
1764 +            P(3, 1) = P(2, 1)
1765 +            P(4, 0) = P(3, 0)
1766 +            P(4, 1) = -Poutre.GetD6
1767 +            P(5, 0) = P(0, 0)
1768 +            P(5, 1) = P(4, 1)
1769 +
1770 +            r(0) = P(1, 0) - 1000 * Epsilon
1771 +            r(1) = 0 : r(2) = 0
1772 +            Outils_Math.Rotation2D(pt3, r(0), r(1))
1773 +            r(0) += TranslationX
1774 +            r(1) += TranslationY
1775 +            r = Commun.TransfertSketchToModel(swSketch, r)
1776 +
1777 +            pt3(0) -= TranslationX
1778 +            pt3(1) -= TranslationY
1779 +            pt3(0) /= longueur : pt3(1) /= longueur
1780 +            For i = 0 To 5
1781 +                Outils_Math.Rotation2D(pt3, P(i, 0), P(i, 1))
1782 +                P(i, 0) += TranslationX
1783 +                P(i, 1) += TranslationY
1784 +            Next i
1785 +
1786 +            ReDim Ligne(35)
1787 +            For i = 0 To 4
1788 +                Ligne(i * 4) = P(i, 0) : Ligne(i * 4 + 1) = P(i, 1) : Ligne(i * 4 + 2) = P(i + 1, 0) : Ligne(i * 4 + 3) = P(i + 1, 1)
1789 +            Next i
1790 +            Ligne(20) = P(5, 0) : Ligne(21) = P(5, 1) : Ligne(22) = P(0, 0) : Ligne(23) = P(0, 1)
1791 +
1792 +            MettreFI = True
1793 +            AjouterMiniPoutre = True
1794 +            AutreSection = False
1795 +
1796 +
1797 +        ElseIf Left(Nomsection, 1) = "T" Or Nomsection = " Poutre en T générique" Then ' le T
1798 +
1799 +            Dim P(7, 1) As Double
1800 +            Dim d As Double
1801 +            d = Poutre.GetD4 * 0.8660254038 '  section.D4 / (2 * tan(30))
1802 +
1803 +            P(0, 0) = -Poutre.GetD5
1804 +            P(0, 1) = Poutre.GetD4 / 2
1805 +            P(1, 0) = P(0, 0)
1806 +            P(1, 1) = -P(0, 1)
1807 +            P(2, 0) = Poutre.GetD1 - Poutre.GetD5 - Poutre.GetD3
1808 +            P(2, 1) = -Poutre.GetD4 / 2.0R
1809 +            P(3, 0) = P(2, 0)
1810 +            P(3, 1) = -Poutre.GetD2 / 2
1811 +            P(4, 0) = Poutre.GetD1 - Poutre.GetD5
1812 +            P(4, 1) = P(3, 1)
1813 +            P(5, 0) = P(4, 0)
1814 +            P(5, 1) = -P(4, 1)
1815 +            P(6, 0) = P(3, 0)
1816 +            P(6, 1) = -P(3, 1)
1817 +            P(7, 0) = P(2, 0)
1818 +            P(7, 1) = -P(2, 1)
1819 +
1820 +
1821 +            r(0) = 0
1822 +            r(1) = 0 : r(2) = 0
1823 +            Outils_Math.Rotation2D(pt3, r(0), r(1))
1824 +            r(0) += TranslationX
1825 +            r(1) += TranslationY
1826 +            r = Commun.TransfertSketchToModel(swSketch, r)
1827 +
1828 +            pt3(0) -= TranslationX
1829 +            pt3(1) -= TranslationY
1830 +            pt3(0) /= longueur : pt3(1) /= longueur
1831 +            For i = 0 To 7
1832 +                Outils_Math.Rotation2D(pt3, P(i, 0), P(i, 1))
1833 +                P(i, 0) += TranslationX
1834 +                P(i, 1) += TranslationY
1835 +            Next i
1836 +
1837 +            ReDim Ligne(31)
1838 +            For i = 0 To 6
1839 +                Ligne(i * 4) = P(i, 0) : Ligne(i * 4 + 1) = P(i, 1) : Ligne(i * 4 + 2) = P(i + 1, 0) : Ligne(i * 4 + 3) = P(i + 1, 1)
1840 +            Next i
1841 +            Ligne(28) = P(7, 0) : Ligne(29) = P(7, 1) : Ligne(30) = P(0, 0) : Ligne(31) = P(0, 1)
1842 +
1843 +            MettreFI = True
1844 +            AjouterMiniPoutre = True
1845 +            AutreSection = False
1846 +
1847  
1848          Else
1849              MsgBox("Section de poutre non reconnu!", MsgBoxStyle.Critical, "Commun.DessineSectionPoutre")
# Line 1863 | Line 1860 | Public Class SuperFace
1860  
1861      End Function
1862  
1863 <    Public Function SwFace() As SldWorks.Face2 ' retourne la première face de la liste (dans la partie traitement, ce sera la seule...)
1863 >
1864 >    Public Function SwFace() As sldworks.Face2 ' retourne la première face de la liste (dans la partie traitement, ce sera la seule...)
1865          Return Me.lst_Faces.Item(0)
1866      End Function
1867  
1868 <    Public Function IsFaceInterne(ByRef swface As SldWorks.Face2) As Boolean
1869 <        Dim attr As SldWorks.Attribute
1870 <        Dim SwEnt As SldWorks.Entity
1868 >    Public Function IsFaceInterne(ByRef swface As sldworks.Face2) As Boolean
1869 >        Dim attr As sldworks.Attribute
1870 >        Dim SwEnt As sldworks.Entity
1871          SwEnt = swface
1872          attr = SwEnt.FindAttribute(DefAttrFaceInterne, 0)
1873          If attr Is Nothing Then Return False Else Return True
# Line 1880 | Line 1878 | Public Class SuperFace
1878      ''' </summary>
1879      ''' <returns>Un tableau de Edges</returns>
1880      ''' <remarks></remarks>
1881 <    Public Function GetAretes() As SldWorks.Edge()
1882 <        Dim face As SldWorks.Face2
1883 <        Dim arete As SldWorks.Edge = Nothing
1884 <        Dim temp2 As Collections.Generic.List(Of SldWorks.Edge)
1885 <        Dim lst As New Collections.Generic.List(Of SldWorks.Edge)
1881 >    Public Function GetAretes() As sldworks.Edge()
1882 >        Dim face As sldworks.Face2
1883 >        Dim arete As sldworks.Edge = Nothing
1884 >        Dim temp2 As Collections.Generic.List(Of sldworks.Edge)
1885 >        Dim lst As New Collections.Generic.List(Of sldworks.Edge)
1886  
1887          For Each face In Me.lst_Faces
1888              temp2 = GetArete1Face(face)
# Line 1896 | Line 1894 | Public Class SuperFace
1894          Return lst.ToArray
1895      End Function
1896  
1897 <    Private Function GetArete1Face(ByRef Face As SldWorks.Face2) As Collections.Generic.List(Of SldWorks.Edge)
1897 >    Private Function GetArete1Face(ByRef Face As sldworks.Face2) As Collections.Generic.List(Of sldworks.Edge)
1898          Dim vArete As Object
1899 <        Dim a As SldWorks.Edge
1900 <        Dim arete() As SldWorks.Edge
1901 <        Dim lst As New Collections.Generic.List(Of SldWorks.Edge)
1899 >        Dim a As sldworks.Edge
1900 >        Dim arete() As sldworks.Edge
1901 >        Dim lst As New Collections.Generic.List(Of sldworks.Edge)
1902  
1903          ReDim arete(Face.GetEdgeCount - 1)
1904          vArete = Face.GetEdges()
# Line 1913 | Line 1911 | Public Class SuperFace
1911      End Function
1912  
1913      Public Overrides Sub Selectionner(Optional ByVal Mark As Integer = 0, Optional ByRef append As Boolean = True)
1914 <        Dim swent As SldWorks.Entity
1915 <        Dim swface As SldWorks.Face2
1914 >        Dim swent As sldworks.Entity
1915 >        Dim swface As sldworks.Face2
1916  
1917          For Each swface In lst_Faces
1918              swent = swface
# Line 1930 | Line 1928 | Public Class SuperFace
1928      ''' <param name="Append"></param>
1929      ''' <remarks></remarks>
1930      Public Sub SelectionnerToutes(Optional ByRef Mark As Integer = 0, Optional ByRef Append As Boolean = True)
1931 <        Dim swFace As SldWorks.Face2
1931 >        Dim swFace As sldworks.Face2
1932  
1933 <        Dim swent As SldWorks.Entity
1933 >        Dim swent As sldworks.Entity
1934          If Append = False Then swModel.ClearSelection2(True)
1935          For Each swFace In Me.lst_Faces
1936              swent = swFace : swent.Select2(True, Mark)
# Line 1943 | Line 1941 | Public Class SuperFace
1941  
1942  
1943      Public Function Couleur(ByRef rouge As Double, ByRef Vert As Double, ByRef Bleu As Double, Optional ByVal Ambient As Double = 1, Optional ByVal Diffuse As Double = 1, Optional ByVal Specular As Double = 1, Optional ByVal Shininess As Double = 0.5, Optional ByVal Transparency As Double = 0, Optional ByVal Emission As Double = 0.2) As Integer
1946
1944          swModel.SelectedFaceProperties(RGB(rouge, Vert, Bleu), Ambient, Diffuse, Specular, Shininess, Transparency, Emission, False, "")
1948
1945          Return 1
1946      End Function
1947  
1952    Public Sub AjouterFace(ByRef face As SldWorks.Face2)
1953        Dim testface As SldWorks.Face2
1954        Dim faultentity As SldWorks.FaultEntity
1955        Dim swent As SldWorks.Entity
1956
1957        If Not Me.lst_Faces.Contains(face) Then Me.lst_Faces.Add(face)
1958
1959        ' vérifier que les anciennes faces sont toujours ok...
1960        For Each testface In Me.lst_Faces
1961            faultentity = testface.Check
1962            If Not faultentity.Count = 0 Then ' on a un problème avec la face....
1963                lst_Faces.Remove(testface)
1964                Dim i As Integer
1965                For i = 0 To faultentity.Count
1966                    swent = faultentity.Entity(i)
1967                    If Not swent Is Nothing Then
1968                        swent.Select4(True, Nothing)
1969                    End If
1970                    Debug.Print("   Fault[" & i & "] = " & swent.errorCode(i))
1971                Next i
1972            End If
1973        Next testface
1974
1948  
1949 +    Public Sub AjouterFace(ByRef face As sldworks.Face2)
1950 +        Me.lst_Faces.Add(face)
1951      End Sub
1952  
1953  
# Line 1996 | Line 1971 | Public Class SuperFace
1971      ''' </summary>
1972      ''' <returns></returns>
1973      ''' <remarks></remarks>
1974 <    Public Function GetFace() As SldWorks.Face2
1974 >    Public Function GetFace() As sldworks.Face2
1975          Return Me.SwFace
1976      End Function
1977  
# Line 2005 | Line 1980 | Public Class SuperFace
1980      ''' </summary>
1981      ''' <returns></returns>
1982      ''' <remarks></remarks>
1983 <    Public Function GetFaces() As SldWorks.Face2()
1983 >    Public Function GetFaces() As sldworks.Face2()
1984          Return Me.lst_Faces.ToArray
1985      End Function
1986  
# Line 2036 | Line 2011 | Public Class SuperFace
2011      ''' <param name="X"></param>
2012      ''' <param name="Y"></param>
2013      ''' <param name="Z"></param>
2014 <    ''' <returns>Vrai si l epoint est sur la face, faux sinon</returns>
2014 >    ''' <returns>Vrai si le point est sur la face, faux sinon</returns>
2015      ''' <remarks>Retourne X, Y et Z même si le point n'est pas sur la face (mais sur la surface) </remarks>
2016      Public Function Evaluer(ByRef U As Double, ByVal V As Double, ByRef X As Double, ByRef Y As Double, ByRef Z As Double) As Boolean
2017 <        Dim surf As SldWorks.Surface
2017 >        Dim surf As sldworks.Surface
2018          Dim vEv As Object, vpoint As Object
2019          Dim P(2) As Double
2020  
# Line 2064 | Line 2039 | Public Class SuperFace
2039      ''' <returns>Un tableau de 3 doubles correspondant à la normale</returns>
2040      ''' <remarks></remarks>
2041      Public Function Normale(ByRef X As Double, ByRef Y As Double, ByRef Z As Double) As Double()
2042 <        Dim surf As SldWorks.Surface
2042 >        Dim surf As sldworks.Surface
2043          Dim vtemp As Object
2044          Dim temp() As Double
2045          Dim sens As Boolean
# Line 2072 | Line 2047 | Public Class SuperFace
2047          surf = SwFace.GetSurface
2048          If surf.IsPlane Then vtemp = SwFace.Normal : temp = vtemp : Return temp ' si la face est plane alors c'est ok, sinon il faut travailler...
2049  
2075
2050          vtemp = surf.EvaluateAtPoint(X, Y, Z)
2051          ReDim temp(2)
2078
2052          ' la normale de la face pointe AWAY from the body
2080
2053          sens = SwFace.FaceInSurfaceSense()  'TRUE if face normal and surface normal are in the opposite direction and FALSE if they are in the same direction
2054  
2083
2055          If sens Then ' on doit inverser
2056              temp(0) = -vtemp(0) : temp(1) = -vtemp(1) : temp(2) = -vtemp(2)
2057          Else
# Line 2090 | Line 2061 | Public Class SuperFace
2061  
2062      End Function
2063  
2064 <
2065 <    Public Sub MettreAttributFaceInterne(Optional ByRef Valeur As Double = 0)
2064 >    ''' <summary>
2065 >    ''' Met un attribut de face interne
2066 >    ''' </summary>
2067 >    ''' <param name="face">La face sur laquelle mettre l'attribut</param>
2068 >    ''' <param name="Valeur">La taille de maille suggérée</param>
2069 >    ''' <param name="poutre">Si vrai alors on a une poutre, sinon une coque</param>
2070 >    ''' <returns>Le numéro de l'attribut (si jamais c'est important)</returns>
2071 >    ''' <remarks>Attention au signe de la valeur</remarks>
2072 >    Public Function MettreAttributFaceInterne(ByRef face As sldworks.Face2, Optional ByRef Valeur As Double = 0, Optional ByVal poutre As Boolean = True) As Integer
2073          Dim no As Integer = 0
2074          Dim nom As String = "FaceInterne" & no
2075 <        Dim swent As SldWorks.Entity
2076 <        Dim attr As SldWorks.Attribute
2075 >        Dim swent As sldworks.Entity
2076 >        Dim attr As sldworks.Attribute
2077 >        Dim p As sldworks.Parameter
2078 >
2079 >        swent = face 'Me.SwFace
2080  
2100        swent = Me.SwFace
2081          attr = swent.FindAttribute(Intersections.DefAttrFaceInterne, 0) ' si l'attribut existe déjà on pointe dessus.
2082 <        If attr Is Nothing Then attr = Intersections.DefAttrFaceInterne.CreateInstance5(swModel, SwFace, nom, 0, 2) ' 0 = swThisconfig
2082 >        If attr Is Nothing Then attr = Intersections.DefAttrFaceInterne.CreateInstance5(swModel, face, nom, 0, 2) ' 0 = swThisconfig
2083          While attr Is Nothing
2084              no += 1
2085              nom = "FaceInterne" & CStr(no)
2086 <            attr = Intersections.DefAttrFaceInterne.CreateInstance5(swModel, SwFace, nom, 0, 2)
2086 >            attr = Intersections.DefAttrFaceInterne.CreateInstance5(swModel, face, nom, 0, 2)
2087          End While
2088 +        p = attr.GetParameter("FI")
2089 +        p.SetDoubleValue(Valeur)
2090 +
2091 +        p = attr.GetParameter("Po")
2092 +        If poutre Then
2093 +            p.SetDoubleValue(0) ' poutre
2094 +        Else
2095 +            p.SetDoubleValue(1) ' coque
2096 +        End If
2097 +
2098 +
2099          GererDossiers("FaceInternes", nom)
2100 +        Return no
2101 +    End Function
2102 +
2103 +    ''' <summary>
2104 +    ''' Si la face est une face interne,alors on écrit les points POG dans le fichier
2105 +    ''' </summary>
2106 +    ''' <remarks></remarks>
2107 +    Public Sub MettrePointSurPOG(ByVal fichier As System.IO.StreamWriter)
2108 +        ' 2 - Si la face a un attribut de faceInterne on:
2109 +        Dim ENG As Double = Commun.ÉcartNodal
2110 +        Dim EcartSouhaite As Double
2111 +        Dim ratio As Double
2112 +
2113 +
2114 +        If Me.PossedeAttributFaceInterne Then
2115 +            ' 2.1 Détermine l'écart nodal à cette face ( en fait, le ratio... )
2116 +
2117 +            ' là on a 2 options,
2118 +            ' a) on utilise le rayon hydraulique: 4* Surface / Périmètre
2119 +            EcartSouhaite = Me.GrosseurMailleFaceInterne ' 4 * Me.Aire / Me.Perimetre
2120 +            If EcartSouhaite <= 0 Then Exit Sub
2121 +            ratio = EcartSouhaite / ENG
2122 +
2123 +
2124 +            If ratio > 0.75 Then ratio = 0.75 ' ?!? on s'assure d'avoir un minimum de rafinement...
2125 +            ' b) On analyse la tessellation et on prend la plus petite longueur de triangle...
2126 +
2127 +            ' 2.2 Créé une série de points [ sur chaque point de la tessellation   :-) ]  mais là on va avoir un tas de doubles... Update.  La tessellation n emarche pas, sur des faces «carrées» il y a des zones trop vides
2128 +            ' On va mettre des points sur le contour des faces.  un point va automatiquement se retrouver au milieu
2129 +
2130 +            Dim objArete As Object = Me.SwFace.GetEdges
2131 +            Dim points As New Collections.Generic.List(Of Point)
2132 +            Dim p As Point
2133 +            Dim x, y, z As Double
2134 +
2135 +
2136 +            For Each swArete As sldworks.Edge In objArete
2137 +                Dim e As New SuperArete(swArete, True)
2138 +                Dim LongueurArete As Double = e.Longueur
2139 +                Dim nbSeg As Integer = Int(LongueurArete / EcartSouhaite / 2) : If nbSeg < 2 Then nbSeg = 2
2140 +                Dim dt As Double = (e.GetTMax - e.GetTMin) / nbSeg
2141 +                Dim T As Double = e.GetTMin
2142 +
2143 +
2144 +                ' les points sur les arètes
2145  
2146 +                For s As Integer = 1 To nbSeg - 1
2147 +                    T += dt
2148 +                    e.Evaluer(T, x, y, z)
2149 +                    p = New Point(x, y, z) : points.Add(p)
2150 +                Next s
2151 +
2152 +
2153 +
2154 +                ' les points sur les sommets
2155 +                Dim swSommets() As sldworks.Vertex = Me.GetSommets
2156 +                Dim es As SuperSommet
2157 +                For Each sommet As sldworks.Vertex In swSommets
2158 +                    es = New SuperSommet(sommet, True)
2159 +                    p = New Point(es.X, es.Y, es.Z) : points.Add(p)
2160 +                Next
2161 +                e = Nothing
2162 +                es = Nothing
2163 +
2164 +            Next
2165 +
2166 +            For Each p In points
2167 +                ' 2.3 enregistre ces points dans le fichier.
2168 +                fichier.WriteLine(CStr(p) & " " & ratio & " " & "4" & " " & "0")
2169 +            Next p
2170 +            ENG = 1 ' pour y mettre un point d'arrêt
2171 +        End If
2172      End Sub
2173  
2174  
2175 +    ''' <summary>
2176 +    ''' Retourne un tableau de swSommets
2177 +    ''' </summary>
2178 +    ''' <returns></returns>
2179 +    ''' <remarks></remarks>
2180 +    Public Function GetSommets() As sldworks.Vertex()
2181 +        Dim lst_sommets As New Collections.Generic.List(Of sldworks.Vertex)
2182 +        Dim swSommet As sldworks.Vertex
2183 +        Dim objArete As Object = Me.SwFace.GetEdges()
2184 +
2185 +        For Each arete As sldworks.Edge In objArete
2186 +            swSommet = arete.GetStartVertex() : If swSommet Is Nothing Then Continue For
2187 +            If Not lst_sommets.Contains(swSommet) Then lst_sommets.Add(swSommet)
2188 +            swSommet = arete.GetEndVertex()
2189 +            If Not lst_sommets.Contains(swSommet) Then lst_sommets.Add(swSommet)
2190 +        Next arete
2191 +        Return lst_sommets.ToArray
2192 +    End Function
2193 +
2194 +
2195 +    ''' <summary>
2196 +    ''' Function qui donne la grosseur des maille que l'on aimerait avoir pour
2197 +    ''' </summary>
2198 +    ''' <returns></returns>
2199 +    ''' <remarks></remarks>
2200 +    Public Function GrosseurMailleFaceInterne() As Double
2201 +        Dim swEnt As sldworks.Entity
2202 +        Dim attr As sldworks.Attribute
2203 +        swEnt = Me.SwFace
2204 +        attr = swEnt.FindAttribute(Intersections.DefAttrFaceInterne, 0)
2205 +        If attr Is Nothing Then Return Nothing
2206 +        Dim p As sldworks.Parameter = attr.GetParameter("FI")
2207 +        Return p.GetDoubleValue
2208 +    End Function
2209 +
2210 +    ''' <summary>
2211 +    ''' Retourne vrai si la face a un attribut de face interne.
2212 +    ''' </summary>
2213 +    ''' <returns></returns>
2214 +    ''' <remarks></remarks>
2215 +    Public Function PossedeAttributFaceInterne() As Boolean
2216 +        Dim swEnt As sldworks.Entity
2217 +        Dim attr As sldworks.Attribute
2218 +        swEnt = Me.SwFace
2219 +        attr = swEnt.FindAttribute(Intersections.DefAttrFaceInterne, 0)
2220 +        If attr Is Nothing Then Return False Else Return True
2221 +    End Function
2222 +
2223 +
2224 +    ''' <summary>
2225 +    ''' Retourne le périmètre de la face
2226 +    ''' </summary>
2227 +    ''' <returns></returns>
2228 +    ''' <remarks>Attention, c'est une approximation!!!</remarks>
2229 +    Public Function Perimetre() As Double
2230 +        Dim objArete As Object = Me.SwFace.GetEdges
2231 +        'Dim swAretes() As sldworks.Edge = objArete
2232 +        Dim longueur As Double
2233 +
2234 +        For Each swArete As sldworks.Edge In objArete
2235 +            Dim e As New SuperArete(swArete, True)
2236 +            longueur += e.Longueur()
2237 +        Next
2238 +        Return longueur
2239 +    End Function
2240 +
2241 +
2242 +    ''' <summary>
2243 +    ''' Retourne la surface (l'aire) de la face
2244 +    ''' </summary>
2245 +    ''' <returns></returns>
2246 +    ''' <remarks></remarks>
2247 +    Public Function Aire() As Double
2248 +        Return Me.SwFace.GetArea
2249 +    End Function
2250 +
2251 +    ''' <summary>
2252 +    ''' Retourne le nombre d'arètes contenues dans la superface
2253 +    ''' </summary>
2254 +    ''' <value></value>
2255 +    ''' <returns></returns>
2256 +    ''' <remarks></remarks>
2257 +    Public ReadOnly Property GetNbAretes() As Integer
2258 +        Get
2259 +            Dim nb As Integer
2260 +            Dim lstFaces() As sldworks.Face2 = Me.SwFace
2261 +            For Each swFace As sldworks.Face2 In lstFaces
2262 +                nb += swFace.GetEdgeCount
2263 +            Next
2264 +            Return nb
2265 +        End Get
2266 +    End Property
2267 +
2268 +    Public Function GetSurface() As sldworks.Surface
2269 +        Return Me.GetFace.GetSurface
2270 +    End Function
2271 +
2272 +
2273 +
2274   End Class

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines