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

Comparing magicsld/SlyFaceCoque.vb (file contents):
Revision 130 by bournival, Wed Jul 30 21:26:03 2008 UTC vs.
Revision 205 by bournival, Thu Jul 23 20:53:57 2009 UTC

# Line 156 | Line 156 | Public Class SlyFaceCoque
156          If Me.estPlan Then
157              ' la coque est plane, on met une esquisse dessus.#
158              PlanEntity = Me.SwFace
159 +            swEnt = PlanEntity
160 +            swEnt.Select2(False, 0)
161 +            planReference = swModel.CreatePlaneAtOffset3(0, False, True)
162  
163          ElseIf Me.estCylindre Then
164              ' on doit créer un plan de référence...
# Line 209 | Line 212 | Public Class SlyFaceCoque
212          Next
213  
214          retval = Arete.GetClosestPointOn(inter.x, inter.y, inter.z)
215 <        retval = Arete.Evaluate(retval(3))
216 <        v(0) = retval(3) : v(1) = retval(4) : v(2) = retval(5)
215 >        Dim t As Double = retval(3)
216 >        retval = Arete.Evaluate(t)
217  
218 +        If t > 0 Then  ' ??????? solidworks inverse les valeurs dans des cas que je ne peut identifier.
219 +            v(0) = retval(3) : v(1) = retval(4) : v(2) = retval(5)
220 +        Else
221 +            v(0) = retval(4) : v(1) = -retval(3) : v(2) = retval(5)
222 +        End If
223  
224  
225  
# Line 244 | Line 252 | Public Class SlyFaceCoque
252              Dim P3(1) As Double
253              Dim P4(1) As Double
254              Dim Ptest(2) As Double
255 +            Dim Ptest2(2) As Double : Ptest2(0) = 0.5 : Ptest2(1) = 0
256 +            Dim Ptest3(2) As Double : Ptest3(0) = 0 : Ptest3(1) = 0.75
257 +            Dim Ptest4(2) As Double : Ptest4(0) = 1.5 : Ptest4(1) = 0
258 +            Dim Ptest5(2) As Double : Ptest5(0) = 0 : Ptest5(1) = 2
259  
260  
261              If g = 0 Then
# Line 255 | Line 267 | Public Class SlyFaceCoque
267                  P3(1) = cut   'Intersections.Taille mult
268                  P4(0) = -cut
269                  P4(1) = cut   'Intersections.Taille mult
270 <                sk(0) = -Epsilon * 100 + base(0) : sk(1) = 0 + base(1)
270 >                'sk(0) = -Epsilon * 100 + base(0) : sk(1) = 0 + base(1)
271 >                sk(0) = -Epsilon * 100 : sk(1) = 0
272  
273              Else
274                  P1(0) = 0
# Line 266 | Line 279 | Public Class SlyFaceCoque
279                  P3(1) = cut  'Intersections.Taille mult
280                  P4(0) = 0
281                  P4(1) = cut  'Intersections.Taille mult
282 <                sk(0) = Epsilon * 100 + base(0) : sk(1) = 0 + base(1)
283 <
282 >                'sk(0) = Epsilon * 100 + base(0) : sk(1) = 0 + base(1)
283 >                sk(0) = Epsilon * 100 : sk(1) = 0
284              End If
285  
286              P1 = Outils_Math.Rotation2D(vsketch, P1)
# Line 275 | Line 288 | Public Class SlyFaceCoque
288              P3 = Outils_Math.Rotation2D(vsketch, P3)
289              P4 = Outils_Math.Rotation2D(vsketch, P4)
290              sk = Outils_Math.Rotation2D(vsketch, sk)
291 +            Ptest4 = Outils_Math.Rotation2D(vsketch, Ptest4)
292 +            Ptest5 = Outils_Math.Rotation2D(vsketch, Ptest5)
293 +
294 +            sk(0) += base(0)
295 +            sk(1) += base(1)
296 +
297 +            Ptest(0) += base(0)
298 +            Ptest(1) += base(1)
299 +
300 +            swModel.CreatePoint2(Ptest(0), Ptest(1), 0)
301 +
302 +            sketchline = swModel.CreateLine2(base(0), base(1), 0, Ptest2(0) + base(0), Ptest2(1) + base(1), 0) : sketchline.ConstructionGeometry = True
303 +            sketchline = swModel.CreateLine2(base(0), base(1), 0, Ptest3(0) + base(0), Ptest3(1) + base(1), 0) : sketchline.ConstructionGeometry = True
304 +            sketchline = swModel.CreateLine2(base(0), base(1), 0, Ptest4(0) + base(0), Ptest4(1) + base(1), 0) : sketchline.ConstructionGeometry = True
305 +            sketchline = swModel.CreateLine2(base(0), base(1), 0, Ptest5(0) + base(0), Ptest5(1) + base(1), 0) : sketchline.ConstructionGeometry = True
306 +            sketchline = swModel.CreateLine2(base(0), base(1), 0, vsketch(0) + base(0), vsketch(1) + base(1), 0) : sketchline.ConstructionGeometry = True
307  
308              sketchline = swModel.CreateLine2(P1(0) + base(0), P1(1) + base(1), 0, P2(0) + base(0), P2(1) + base(1), 0)
309              sketchline = swModel.CreateLine2(P2(0) + base(0), P2(1) + base(1), 0, P3(0) + base(0), P3(1) + base(1), 0)
310              sketchline = swModel.CreateLine2(P3(0) + base(0), P3(1) + base(1), 0, P4(0) + base(0), P4(1) + base(1), 0)
311              sketchline = swModel.CreateLine2(P1(0) + base(0), P1(1) + base(1), 0, P4(0) + base(0), P4(1) + base(1), 0)
312  
313 +
314 +
315              swModel.InsertSketch2(True) ' l'option true rebuild le modèle avec les modifications du sketch.
316              swModel.ClearSelection2(True)
317              'swEnt = Me.SwFace : swEnt.Select2(False, 1)
# Line 289 | Line 320 | Public Class SlyFaceCoque
320  
321              swModel.InsertSplitLineProject(Directionnel, Flip)
322              r = Commun.TransfertSketchToModel(swSketch, sk)
323 <            Face(g) = UpdateApresSplit(inter, poutre, r(0), r(1), r(2), planReference, , True)
323 >            Face(g) = UpdateApresSplit(inter, poutre, r(0), r(1), r(2), planReference, , False)
324              'If Face(g) Is Nothing Then
325              'swSketch.Select(False)
326              'swModel.EditDelete()
327              'End If
328  
329 +
330          Next g
331  
332  
# Line 522 | Line 554 | Public Class SlyFaceCoque
554  
555  
556  
557 <    Protected 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, Optional ByVal VientDeCoupeCote As Boolean = False) As sldworks.Face2
557 >    Protected 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, Optional ByVal ajouterMini As Boolean = False) As sldworks.Face2
558  
559          ' le pointeur Me.swFace pointe soit sur une face, soit sur la face originale soit la face découpée  
560          ' cette procédure doit créer une nouvelle SlyFaceCoque
# Line 533 | Line 565 | Public Class SlyFaceCoque
565  
566          ' 1 - on obtient les 2 nouvelles faces,
567          Dim vFace As Object
568 <        Dim Face1 As sldworks.Face2
537 <        Dim Face2 As sldworks.Face2
568 >        Dim Face As sldworks.Face2 = Nothing
569          Dim FaceInterne As sldworks.Face2
539        Dim FaceExterne As sldworks.Face2
570          Dim swFeat As sldworks.Feature
571 +        Dim swent As sldworks.Entity = Nothing
572 +        Dim swFaultEnt As sldworks.FaultEntity
573  
574          swFeat = swModel.FeatureByPositionReverse(0)
575 <        vFace = swFeat.GetFaces
575 >        Try
576 >            vFace = swFeat.GetFaces
577 >            For Each Face In vFace
578 >                Me.lst_Faces.Add(Face)
579 >            Next Face
580 >        Catch
581 >            ' si on a une poutre dessinée en partie, on aura pas de feature... mais on a la face...
582 >            ' on doit donc le déterminer anyway
583 >        End Try
584  
545        If vFace Is Nothing Then Return Nothing ' le code nothing veut dire que la face n'a pas été coupée.
585  
547        Face1 = vFace(0)
548        Face2 = vFace(1)
586  
587 <        Try ' vérification
588 <            Dim face3 As sldworks.Face2
589 <            Dim i As Integer
590 <            'Dim slyFaceSupplémentaire As SlyFaceCoque ' la raison du pourquoi on doit avoir 2 sous-routines
587 >        For Each Face In Me.lst_Faces  ' à revoir
588 >            swFaultEnt = Face.Check
589 >            If Not IsNothing(swFaultEnt) Then
590 >                Me.lst_Faces.GetEnumerator()
591 >            End If
592 >        Next Face
593  
555            For i = 2 To 1000
556                face3 = vFace(i)
557                Me.lst_Faces.Add(face3)
558            Next i
594  
595 <            'MsgBox("Problème, on a au moins 3 face dans le update après le découpage", MsgBoxStyle.Critical)
596 <        Catch ex As Exception
597 <            ' tout est normal...
598 <        End Try
595 >        ' on créé un point dans un sketch et on le place
596 >        ' This method projects the selected sketch items from the current sketch on a selected surface.
597 >        ' en fait ça projette juste une courbe...  
598 >        ' et si ça retourne nul alors la projection a pas marchée.
599 >        Dim swSKSeg As sldworks.SketchSegment
600 >        swSKSeg = Commun.MettreUneLigne(Plan, x - 20 * Epsilon, y - 20 * Epsilon, z, x + 20 * Epsilon, y + 20 * Epsilon, z)
601 >
602 >        swFeat = Nothing
603 >        For Each Face In Me.lst_Faces
604 >            swSKSeg.Select4(False, Nothing)
605 >            swent = Face : swent.Select4(True, Nothing)
606 >            swFeat = swModel.InsertProjectedSketch2(0) ' 1 pour inverser la direction de la projection
607 >            If swFeat IsNot Nothing Then Exit For
608 >            swFeat = swModel.InsertProjectedSketch2(1) ' 1 pour inverser la direction de la projection
609 >            If swFeat IsNot Nothing Then Exit For
610 >        Next Face
611 >
612 >
613 >        If swFeat Is Nothing Then
614 >            ' on passe à un autre type d'essai...
615 >            Dim dist As Double
616 >            For Each Face In Me.lst_Faces
617 >                dist = swModel.ClosestDistance(Face, swSKSeg, Nothing, Nothing)
618 >                If Math.Abs(dist) < Epsilon Then FaceInterne = Face : Exit For
619 >            Next Face
620  
565        ' SECRET 1.999 ' c'est pas scientifique mais ça peut marcher
566        If Math.Abs(Face1.GetArea) > Math.Abs(10 * Face2.GetArea) Then
567            FaceInterne = Face2
568            FaceExterne = Face1
569        ElseIf Math.Abs(Face1.GetArea) < Math.Abs(10 * Face2.GetArea) Then
570            FaceInterne = Face1
571            FaceExterne = Face2
572        Else
621  
622 +            If FaceInterne Is Nothing Then MsgBox("N'a pas réussi à trouver la bonne face dans le UpdateAPrèsSplit")
623 +            Return Nothing
624  
575            '' 2 - on a un point, on trouve quelle face est la plus proche.
576            If Commun.Distance(Face1, x, y, z) < Commun.Distance(Face2, x, y, z) Then
577                FaceInterne = Face1
578                FaceExterne = Face2
579            Else
580                FaceInterne = Face2
581                FaceExterne = Face1
582            End If
583        End If
625  
626 <        Me.lst_Faces.Add(FaceInterne)
627 <        Me.lst_Faces.Add(FaceExterne)
626 >        Else
627 >            FaceInterne = Face
628 >            ' effacer le feature...
629 >        End If
630  
588        '' 3 - on créé une nouvelle coque (intérieure) et on lui donne les propriétés originales et on met dans la liste des coques
589        'Me.swFace = FaceExterne
590        Dim aire As Double
591        aire = FaceExterne.GetArea
631  
632          ' ************************************************
633          ' pour placer un attribut sur la face interne
595        Dim attr As sldworks.Attribute
596        Dim swent As sldworks.Entity
634          Static no As Integer
635  
636 <        If FI Then
637 <            Dim nom2 As String = "FaceInterne" & no
636 >        If FI Then no = Me.MettreAttributFaceInterne(FaceInterne, poutre.SuggereGrosseurMaille, True)
637 >        If ajouterMini Then MyBase.AjouterMiniPoutresSurFaceInterne(poutre, FaceInterne, inter.x, inter.y, inter.z)
638  
602            swent = FaceInterne
603            attr = swent.FindAttribute(Intersections.DefAttrFaceInterne, 0) ' si l'attribut existe déjà on pointe dessus.
639  
640 <            If attr Is Nothing Then attr = Intersections.DefAttrFaceInterne.CreateInstance5(swModel, FaceInterne, nom2, 0, 2) ' 0 = swThisconfig
640 >        'If FI Then
641 >        '    Dim nom2 As String = "FaceInterne" & no
642  
643 <            While attr Is Nothing
644 <                no += 1
609 <                nom2 = "FaceInterne" & CStr(no)
610 <                attr = Intersections.DefAttrFaceInterne.CreateInstance5(swModel, FaceInterne, nom2, 0, 2)
611 <            End While
612 <            GererDossiers("FaceInternes", nom2)
613 <            no += 1
614 <        ElseIf Flag = 2 Then ' on a un channel, on fait les 2 options
615 <            Dim nom2 As String = "FaceInterne" & no
643 >        '    swent = FaceInterne
644 >        '    attr = swent.FindAttribute(Intersections.DefAttrFaceInterne, 0) ' si l'attribut existe déjà on pointe dessus.
645  
646 <            swent = FaceInterne
618 <            attr = swent.FindAttribute(Intersections.DefAttrFaceInterne, 0) ' si l'attribut existe déjà on pointe dessus.
646 >        '    If attr Is Nothing Then attr = Intersections.DefAttrFaceInterne.CreateInstance5(swModel, FaceInterne, nom2, 0, 2) ' 0 = swThisconfig
647  
648 <            If attr Is Nothing Then attr = Intersections.DefAttrFaceInterne.CreateInstance5(swModel, FaceInterne, nom2, 0, 2) ' 0 = swThisconfig
648 >        '    While attr Is Nothing
649 >        '        no += 1
650 >        '        nom2 = "FaceInterne" & CStr(no)
651 >        '        attr = Intersections.DefAttrFaceInterne.CreateInstance5(swModel, FaceInterne, nom2, 0, 2)
652 >        '    End While
653 >        '    GererDossiers("FaceInternes", nom2)
654 >        '    no += 1
655 >        'ElseIf Flag = 2 Then ' on a un channel, on fait les 2 options
656 >        '    Dim nom2 As String = "FaceInterne" & no
657  
658 <            While attr Is Nothing
659 <                no += 1
624 <                nom2 = "FaceInterne" & CStr(no)
625 <                attr = Intersections.DefAttrFaceInterne.CreateInstance5(swModel, FaceInterne, nom2, 0, 2)
626 <            End While
627 <            GererDossiers("FaceInternes", nom2)
628 <            no += 1
629 <            MyBase.AjouterMiniPoutresSurFaceInterne(poutre, FaceInterne, inter.x, inter.y, inter.z)
630 <        Else
631 <            If Not VientDeCoupecote Then MyBase.AjouterMiniPoutresSurFaceInterne(poutre, FaceInterne, inter.x, inter.y, inter.z)
632 <        End If
658 >        '    swent = FaceInterne
659 >        '    attr = swent.FindAttribute(Intersections.DefAttrFaceInterne, 0) ' si l'attribut existe déjà on pointe dessus.
660  
661 <        '  ************ l'attribut de la condition aux limites *******************
635 <        'attr = Nothing
636 <        'Dim nom3 As String
637 <        'Dim p As SldWorks.Parameter
638 <        'If Not Me.condition = "" Then
639 <        '    nom3 = "CLc_" & no & "_" & Me.nom & " " & Me.condition
640 <        '    attr = swent.FindAttribute(Intersections.DefAttrConditionLimite, 0) ' si l'attribut existe déjà on pointe dessus.
661 >        '    If attr Is Nothing Then attr = Intersections.DefAttrFaceInterne.CreateInstance5(swModel, FaceInterne, nom2, 0, 2) ' 0 = swThisconfig
662  
663          '    While attr Is Nothing
664 <        '        If attr Is Nothing Then attr = Intersections.DefAttrConditionLimite.CreateInstance5(swModel, FaceInterne, nom3, 0, 0)
665 <        '        If attr Is Nothing Then nom3 = nom3 & CStr(Timer)
664 >        '        no += 1
665 >        '        nom2 = "FaceInterne" & CStr(no)
666 >        '        attr = Intersections.DefAttrFaceInterne.CreateInstance5(swModel, FaceInterne, nom2, 0, 2)
667          '    End While
668 +        '    GererDossiers("FaceInternes", nom2)
669 +        '    no += 1
670 +        '    MyBase.AjouterMiniPoutresSurFaceInterne(poutre, FaceInterne, inter.x, inter.y, inter.z)
671 +        'Else
672 +        '    If Not VientDeCoupecote Then MyBase.AjouterMiniPoutresSurFaceInterne(poutre, FaceInterne, inter.x, inter.y, inter.z)
673 +        'End If
674  
675 <        '    p = attr.GetParameter("CL")
676 <        '    p.SetStringValue(Me.condition)
675 >        '  ************ l'attribut de la condition aux limites *******************
676 >        Dim attr As sldworks.Attribute
677 >        attr = Nothing
678 >        Dim nom3 As String
679 >        Dim p As sldworks.Parameter
680 >        If Not Me.condition = "" Then
681 >            nom3 = "CLc_" & no & "_" & Me.nom & " " & Me.condition
682 >            attr = swent.FindAttribute(Intersections.DefAttrConditionLimite, 0) ' si l'attribut existe déjà on pointe dessus.
683  
684 <        'End If
685 <        ' GererDossiers("Conditions Aux Limites", nom3)
684 >            While attr Is Nothing
685 >                If attr Is Nothing Then attr = Intersections.DefAttrConditionLimite.CreateInstance5(swModel, FaceInterne, nom3, 0, 0)
686 >                If attr Is Nothing Then nom3 = nom3 & CStr(Timer)
687 >            End While
688 >
689 >            p = attr.GetParameter("CL")
690 >            p.SetStringValue(Me.condition)
691 >
692 >        End If
693 >        GererDossiers("Conditions Aux Limites", nom3)
694          ' *****************************************************
695          Return FaceInterne
696  
# Line 779 | Line 821 | Public Class SlyFaceCoque
821          sens = Me.SwFace.FaceInSurfaceSense()
822  
823          ' 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.
824 <        Dim i As Integer, MettreFI As Boolean
824 >        Dim i As Integer = 0, MettreFI As Boolean
825          Dim swFeat As sldworks.Feature
826 +        Dim autresection As Boolean = True
827 +        Dim AjouterMiniPoutre As Boolean = False
828  
829 <        For i = 0 To 1
830 <
829 >        Do While autresection = True
830 >            i += 1
831              swEnt = planReference
832              swEnt.Select(False)
833              swModel.InsertSketch2(False)
# Line 797 | Line 841 | Public Class SlyFaceCoque
841              retour = Commun.TransfertModelSketch(swsketch, p)
842  
843  
844 <            r = DessineSectionPoutre(poutre, retour(0), retour(1), i + 1, swsketch, inter, MettreFI)
844 >            If SectionSimpleSurPoutre = True Then
845 >                r = DessineSectionPoutreSimple(poutre, retour(0), retour(1), i, swsketch, CType(inter, InterAreteFace), MettreFI, autresection, AjouterMiniPoutre)
846 >            Else
847 >                r = DessineSectionPoutre(poutre, retour(0), retour(1), i, swsketch, CType(inter, InterAreteFace), MettreFI, autresection, AjouterMiniPoutre)
848 >            End If
849 >
850 >
851 >
852              swModel.InsertSketch2(True) ' l'option true rebuild le modèle avec les modifications du sketch.
853              swModel.ClearSelection2(True)
854  
# Line 813 | Line 864 | Public Class SlyFaceCoque
864              Me.SwFace.DetachSurface()
865              Me.SwFace.AttachSurface(LaSurface, sens)
866  
867 <            Faces(i) = UpdateApresSplit(inter, poutre, r(0), r(1), r(2), planReference, MettreFI)
867 >            Faces(i) = UpdateApresSplit(inter, poutre, r(0), r(1), r(2), planReference, MettreFI, AjouterMiniPoutre)
868              Commun.MettreUnPoint(r(0), r(1), r(2))
869  
870              If Faces(i) Is Nothing Then
871                  swEnt.Select(False)
872                  swModel.EditDelete()
873              End If
874 <            If Flag = 2 Then Flag = 0 : Exit For
874 >        Loop
875 >
876  
825        Next i
877      End Sub
878  
879  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines