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

Comparing magicsld/RCCode.vb (file contents):
Revision 48 by bournival, Wed Aug 22 21:18:12 2007 UTC vs.
Revision 130 by bournival, Wed Jul 30 21:26:03 2008 UTC

# Line 6 | Line 6 | Namespace RealConstant
6      Module RCCode
7  
8  
9 <        Public GroupPoutre As SldWorks.PropertyManagerPageGroup
10 <        Public GroupCoque As SldWorks.PropertyManagerPageGroup
11 <        Public RCCheckFacedeSection As SldWorks.PropertyManagerPageCheckbox
12 <        Public RCCheckFacedeSectionCoque As SldWorks.PropertyManagerPageCheckbox
13 <        Public RCcombo1 As SldWorks.PropertyManagerPageCombobox ' matériau poutre
14 <        Public RCcombo2 As SldWorks.PropertyManagerPageCombobox ' section poutre
15 <        Public RCcombo3 As SldWorks.PropertyManagerPageCombobox ' matériau coque
16 <        Public RCselection1 As SldWorks.PropertyManagerPageSelectionbox ' les poutres
17 <        Public RCselection2 As SldWorks.PropertyManagerPageSelectionbox ' le troisième point
18 <        Public RCselection3 As SldWorks.PropertyManagerPageSelectionbox ' les coques
19 <        Public RCNumberbox1 As SldWorks.PropertyManagerPageNumberbox ' I1
20 <        Public RCNumberbox2 As SldWorks.PropertyManagerPageNumberbox ' I2
21 <        Public RCNumberboxD1 As SldWorks.PropertyManagerPageNumberbox
22 <        Public RCNumberboxD2 As SldWorks.PropertyManagerPageNumberbox
23 <        Public RCNumberboxD3 As SldWorks.PropertyManagerPageNumberbox
24 <        Public RCNumberboxD4 As SldWorks.PropertyManagerPageNumberbox
25 <        Public RCNumberboxD5 As SldWorks.PropertyManagerPageNumberbox
26 <        Public RCNumberboxD6 As SldWorks.PropertyManagerPageNumberbox
27 <        Public RCNumberbox5 As SldWorks.PropertyManagerPageNumberbox
28 <        Public RCNumberbox6 As SldWorks.PropertyManagerPageNumberbox    ' épaisseur de la coque
29 <
30 <        Public LabelD1 As SldWorks.PropertyManagerPageLabel
31 <        Public LabelD2 As SldWorks.PropertyManagerPageLabel
32 <        Public LabelD3 As SldWorks.PropertyManagerPageLabel
33 <        Public LabelD4 As SldWorks.PropertyManagerPageLabel
34 <        Public LabelD5 As SldWorks.PropertyManagerPageLabel
35 <        Public LabelD6 As SldWorks.PropertyManagerPageLabel
9 >        Public GroupPoutre As sldworks.PropertyManagerPageGroup
10 >        Public GroupCoque As sldworks.PropertyManagerPageGroup
11 >        Public RCCheckFacedeSection As sldworks.PropertyManagerPageCheckbox
12 >        Public RCCheckFacedeSectionCoque As sldworks.PropertyManagerPageCheckbox
13 >        Public RCcombo1 As sldworks.PropertyManagerPageCombobox ' matériau poutre
14 >        Public RCcombo2 As sldworks.PropertyManagerPageCombobox ' section poutre
15 >        Public RCcombo3 As sldworks.PropertyManagerPageCombobox ' matériau coque
16 >        Public RCselection1 As sldworks.PropertyManagerPageSelectionbox ' les poutres
17 >        Public RCselection2 As sldworks.PropertyManagerPageSelectionbox ' le troisième point
18 >        Public RCselection3 As sldworks.PropertyManagerPageSelectionbox ' les coques
19 >        Public RCNumberbox1 As sldworks.PropertyManagerPageNumberbox ' I1
20 >        Public RCNumberbox2 As sldworks.PropertyManagerPageNumberbox ' I2
21 >        Public RCNumberboxD1 As sldworks.PropertyManagerPageNumberbox
22 >        Public RCNumberboxD2 As sldworks.PropertyManagerPageNumberbox
23 >        Public RCNumberboxD3 As sldworks.PropertyManagerPageNumberbox
24 >        Public RCNumberboxD4 As sldworks.PropertyManagerPageNumberbox
25 >        Public RCNumberboxD5 As sldworks.PropertyManagerPageNumberbox
26 >        Public RCNumberboxD6 As sldworks.PropertyManagerPageNumberbox
27 >        Public RCNumberbox5 As sldworks.PropertyManagerPageNumberbox
28 >        Public RCNumberbox6 As sldworks.PropertyManagerPageNumberbox    ' épaisseur de la coque
29 >
30 >        Public LabelD1 As sldworks.PropertyManagerPageLabel
31 >        Public LabelD2 As sldworks.PropertyManagerPageLabel
32 >        Public LabelD3 As sldworks.PropertyManagerPageLabel
33 >        Public LabelD4 As sldworks.PropertyManagerPageLabel
34 >        Public LabelD5 As sldworks.PropertyManagerPageLabel
35 >        Public LabelD6 As sldworks.PropertyManagerPageLabel
36  
37          Private lst_Section As New Collection ' liste des sections de poutres
38  
39          Private compteur As Long
40  
41 +        Private lstSelection1 As New Collections.Generic.List(Of sldworks.Entity) ' poutre
42 +        Private lstSelection2 As New Collections.Generic.List(Of Object) ' troisième point
43 +        Private lstSelection3 As New Collections.Generic.List(Of sldworks.Entity) ' coque
44 +
45 +        Private FaceDeSectionPoutre As Boolean
46 +        Private FaceDeSectionCoque As Boolean
47 +        Private ModEpaisseur As Double
48 +        Private GroupPoutre1 As Boolean
49 +        Private GroupCoque1 As Boolean
50 +
51 +        Private m As String
52 +        Private s As String
53 +        Private I1 As Double
54 +        Private I2 As Double
55 +        Private D1 As Double
56 +        Private D2 As Double
57 +        Private D3 As Double
58 +        Private D4 As Double
59 +        Private D5 As Double
60 +        Private D6 As Double
61 +        Private As1 As Double
62 +        Private Flag As Double
63 +
64 +
65          Private Structure materiau
66              Dim nom As String
67              Dim E As Double
# Line 46 | Line 70 | Namespace RealConstant
70          End Structure
71  
72  
73 +        ''' <summary>
74 +        ''' Niaiserie nécessaire pour éviter un PureVirtualFnction Call
75 +        ''' </summary>
76 +        ''' <remarks></remarks>
77 +        Public Sub memoriser()
78 +            Dim selMgr As sldworks.SelectionMgr = swModel.SelectionManager
79 +            Dim swEnt As sldworks.Entity
80 +            FaceDeSectionCoque = RCCheckFacedeSectionCoque.Checked
81 +            FaceDeSectionPoutre = RCCheckFacedeSection.Checked
82 +            ModEpaisseur = RCNumberbox6.Value
83 +            GroupCoque1 = GroupCoque.Checked
84 +            GroupPoutre1 = GroupPoutre.Checked
85 +            lstSelection1.Clear()
86 +            lstSelection2.Clear()
87 +            lstSelection3.Clear()
88 +            For i As Integer = 1 To selMgr.GetSelectedObjectCount2(-1) + 1
89 +                If selMgr.GetSelectedObjectType3(i, -1) = swconst.swSelectType_e.swSelFACES Then
90 +                    swEnt = selMgr.GetSelectedObject6(i, -1) : lstSelection3.Add(swEnt)
91 +                End If
92 +            Next
93 +
94 +            ' bon, faut aussi mémoriser les infos des poutres...
95 +
96 +            'swSelectType_e.swSelVERTICES, swSelectType_e.swSelSKETCHPOINTS, swSelectType_e.swSelEXTSKETCHPOINTS
97 +
98 +            For i As Integer = 1 To selMgr.GetSelectedObjectCount2(-1) + 1
99 +                If selMgr.GetSelectedObjectType3(i, -1) = swconst.swSelectType_e.swSelEDGES Or selMgr.GetSelectedObjectType3(i, -1) = &H33 Then
100 +                    swEnt = selMgr.GetSelectedObject6(i, -1) : lstSelection1.Add(swEnt)
101 +                End If
102 +            Next
103 +
104 +            For i As Integer = 1 To selMgr.GetSelectedObjectCount2(-1) + 1
105 +                If selMgr.GetSelectedObjectType3(i, -1) = swconst.swSelectType_e.swSelPOINTREFS Or selMgr.GetSelectedObjectType3(i, -1) = swSelectType_e.swSelVERTICES Or selMgr.GetSelectedObjectType3(i, -1) = swSelectType_e.swSelSKETCHPOINTS Then
106 +                    swEnt = selMgr.GetSelectedObject6(i, -1) : lstSelection2.Add(swEnt)
107 +                End If
108 +                If selMgr.GetSelectedObjectType3(i, -1) = swSelectType_e.swSelEXTSKETCHPOINTS Then
109 +                    Dim obj As Object
110 +                    obj = selMgr.GetSelectedObject6(i, -1)
111 +                    lstSelection2.Add(obj)
112 +                End If
113 +            Next
114 +
115 +
116 +
117 +            m = RCcombo1.ItemText(RCcombo1.CurrentSelection)
118 +            s = RCcombo2.ItemText(RCcombo2.CurrentSelection)
119 +            I1 = RCNumberbox1.Value
120 +            If I1 <= 0 Then MsgBox("La valeur de l'inertie principale est incorrecte", MsgBoxStyle.Critical, "Une valeur doit être modifiée") ' : CreationAttributPourPoutre = False : Exit Sub
121 +            I2 = RCNumberbox2.Value
122 +            If I2 <= 0 Then MsgBox("La valeur de l'inertie secondaire est incorrecte", MsgBoxStyle.Critical, "Une valeur doit être modifiée") ': CreationAttributPourPoutre = False : Exit Sub
123 +            D1 = RCNumberboxD1.Value
124 +            If D1 <= 0 Then MsgBox("La valeur de la longueur dans la direction principale (Ixx) est incorrecte", MsgBoxStyle.Critical, "Une valeur doit être modifiée") ': CreationAttributPourPoutre = False : Exit Sub
125 +            D2 = RCNumberboxD2.Value
126 +            If D2 <= 0 Then MsgBox("La valeur de la longueur dans la direction secondaire (Iyy) est incorrecte", MsgBoxStyle.Critical, "Une valeur doit être modifiée") ': CreationAttributPourPoutre = False : Exit Sub
127 +
128 +            D3 = RCNumberboxD3.Value
129 +            If D3 <= 0 Then MsgBox("La valeur de la longueur D3 est incorrecte", MsgBoxStyle.Critical, "Une valeur doit être modifiée") ' : CreationAttributPourPoutre = False : Exit Sub
130 +            D4 = RCNumberboxD4.Value
131 +            If D4 <= 0 Then MsgBox("La valeur de la longueur D4) est incorrecte", MsgBoxStyle.Critical, "Une valeur doit être modifiée") ' : CreationAttributPourPoutre = False : Exit Sub
132 +            D5 = RCNumberboxD5.Value
133 +            If D5 <= 0 Then MsgBox("La valeur de la longueur D5 est incorrecte", MsgBoxStyle.Critical, "Une valeur doit être modifiée") ': CreationAttributPourPoutre = False : Exit Sub
134 +            D6 = RCNumberboxD6.Value
135 +            If D6 <= 0 Then MsgBox("La valeur de la longueur D6) est incorrecte", MsgBoxStyle.Critical, "Une valeur doit être modifiée") ': CreationAttributPourPoutre = False : Exit Sub
136 +
137 +            As1 = RCNumberbox5.Value
138 +            If As1 <= 0 Then MsgBox("La valeur de l'aide de section est incorrecte", MsgBoxStyle.Critical, "Une valeur doit être modifiée") ' : CreationAttributPourPoutre = False : Exit Sub
139 +
140 +
141 +        End Sub
142 +
143 +
144          Public Function debut() As Boolean
145 +
146              RegisterAttribut()
147 <            If GroupPoutre.Checked = True Then
148 <                If Not GestionAttributPoutre() Then debut = False
147 >            If GroupPoutre1 Then
148 >                If Not GestionAttributPoutre() Then Return False Else Return True
149              End If
150 <            If GroupCoque.Checked = True Then
151 <                If Not GestionAttributCoque() Then debut = False : Exit Function
150 >            If GroupCoque1 = True Then
151 >                If Not GestionAttributCoque() Then Return False Else Return True
152              End If
153 <            If GroupPoutre.Checked = False And GroupCoque.chexked = False Then MsgBox("Vous devez cocher les options que vous désirez avoir, les poutres, les coques ou les deux" & Chr(13) & "Aucune valeurs mémorisées", MsgBoxStyle.Critical, "Aucun groupe choisit")
153 >            If GroupPoutre.Checked = False AndAlso GroupCoque1 = False Then MsgBox("Vous devez cocher les options que vous désirez avoir, les poutres, les coques ou les deux" & Chr(13) & "Aucune valeurs mémorisées", MsgBoxStyle.Critical, "Aucun groupe choisit")
154  
155          End Function
156  
# Line 66 | Line 162 | Namespace RealConstant
162  
163              Dim obj As Object
164              Dim swArete As SldWorks.Edge
69            Dim i As Integer
70            Dim N3 As String
71            Dim iN3 As Long
165  
166 <            If RCselection2.ItemCount > 1 Then MsgBox("Attention, plus d'un point est sélectionné comme troisième point!" & Chr(13) & "     Seul le dernier sera pris en compte.", MsgBoxStyle.Information, "Mauvaise sélection")
166 >            Dim N3 As String = CStr(Rnd())
167  
168 <            Dim SelMgr As SldWorks.SelectionMgr
169 <            Dim swEnt As SldWorks.Entity
168 >
169 >            If lstSelection2.Count > 1 Then MsgBox("Attention, plus d'un point est sélectionné comme troisième point!" & Chr(13) & "     Seul le dernier sera pris en compte.", MsgBoxStyle.Information, "Mauvaise sélection")
170 >
171 >
172 >            Dim SelMgr As sldworks.SelectionMgr
173 >            Dim swEnt As sldworks.Entity
174              SelMgr = swModel.SelectionManager
175  
176 <            If RCselection1.ItemCount = 0 Then MsgBox("Vous devez sélectionner au moins une arête!", MsgBoxStyle.Critical, "Impossible d'exécuter la commande") : GestionAttributPoutre = False : Exit Function
177 <            If RCselection2.ItemCount = 0 AndAlso Not RCCheckFacedeSection.Checked Then MsgBox("Il n'y a pas de troisième point sélectionné, l'origine sera considérée." & vbCr & "Si la poutre a une section circulaire ceci ne cause pas de prolèmes, sinon veillez modifier les informations.", MsgBoxStyle.Exclamation, "Problème potentiel")
176 >            If lstSelection1.Count = 0 Then MsgBox("Vous devez sélectionner au moins une arête!", MsgBoxStyle.Critical, "Impossible d'exécuter la commande") : GestionAttributPoutre = False : Exit Function
177 >            If lstSelection2.Count = 0 AndAlso Not FaceDeSectionPoutre Then MsgBox("Il n'y a pas de troisième point sélectionné, l'origine sera considérée." & vbCr & "Si la poutre a une section circulaire ceci ne cause pas de prolèmes, sinon veillez modifier les informations.", MsgBoxStyle.Exclamation, "Problème potentiel")
178  
179  
180              ' dans les entités sélectionnées il y a un point et une ou plusieurs arêtes, faut noter le point et construire une
181              'liste des arêtes.  Puis on traite la liste des arêtes.
182              Dim lst_poutres As New Collection
183  
87            For i = 1 To SelMgr.GetSelectedObjectCount
184  
185 <                'MsgBox(SelMgr.GetSelectedObjectType2(i))
186 <                Select Case SelMgr.GetSelectedObjectType2(i)
185 >            For z As Integer = 0 To lstSelection1.Count - 1
186 >
187 >                swEnt = lstSelection1.Item(z)
188 >
189 >                swArete = swEnt
190 >
191 >                '   on se débarasse des arètes qui sont sur une coque ou sur un volume
192 >                Dim testArete As Object
193 >                testArete = swArete.GetTwoAdjacentFaces2()
194 >
195 >                If testArete(1) Is Nothing And testArete(0) Is Nothing Then 'MsgBox("L'arête est une poutre")
196 >                    lst_poutres.Add(swEnt)
197 >
198 >                ElseIf testArete(1) Is Nothing Then
199 >                    MsgBox("Une arête sélectionnée appartient à une coque.  Elle ne sera pas prise en compte", MsgBoxStyle.Information)
200 >                Else : MsgBox("Une arête sélectionnée appartient à un volume.  Elle ne sera pas prise en compte", MsgBoxStyle.Information)
201 >                End If
202 >            Next
203  
92                    Case swSelectType_e.swSelEDGES, swSelectType_e.swSelREFEDGES 'on a une arète
93                        swEnt = SelMgr.GetSelectedObject5(i)
204  
205 <                        swArete = swEnt
205 >            For z As Integer = 0 To lstSelection2.Count - 1
206 >                obj = lstSelection2.Item(z) 'SelMgr.GetSelectedObject5(i)
207  
208 <                        '   on se débarasse des arètes qui sont sur une coque ou sur un volume
209 <                        Dim testArete As Object
210 <                        testArete = swArete.GetTwoAdjacentFaces2()
208 >                N3 = Creation3iemePoint(obj) ', SelMgr)
209 >                'iN3 = i
210 >                'N3 = Creation3iemePoint(i, SelMgr) ' attention, ça ça enlève la sélection que l'on a besoin après.
211 >            Next
212  
213  
214 <                        If testArete(1) Is Nothing And testArete(0) Is Nothing Then 'MsgBox("L'arête est une poutre")
215 <                            lst_poutres.Add(swEnt)
214 >            ' For i = 1  'SelMgr.GetSelectedObjectCount
215 >            '    Select Case SelMgr.GetSelectedObjectType2(i)
216  
217 <                        ElseIf testArete(1) Is Nothing Then
218 <                            MsgBox("Une arête sélectionnée appartient à une coque.  Elle ne sera pas prise en compte", MsgBoxStyle.Information)
107 <                        Else : MsgBox("Une arête sélectionnée appartient à un volume.  Elle ne sera pas prise en compte", MsgBoxStyle.Information)
108 <                        End If
217 >            '        Case swSelectType_e.swSelEDGES, swSelectType_e.swSelREFEDGES 'on a une arète
218 >            '            swEnt = SelMgr.GetSelectedObject5(i)
219  
220 <                    Case swSelectType_e.swSelVERTICES, swSelectType_e.swSelSKETCHPOINTS, swSelectType_e.swSelEXTSKETCHPOINTS
111 <                        obj = SelMgr.GetSelectedObject5(i)
112 <                        iN3 = i
113 <                        'N3 = Creation3iemePoint(i, SelMgr) ' attention, ça ça enlève la sélection que l'on a besoin après.
220 >            '            swArete = swEnt
221  
222 <                    Case swSelectType_e.swSelCOORDSYS
223 <                        ' on vient de cliquer sur un système de coordonnées.
224 <                        swEnt = SelMgr.GetSelectedObject5(i)
225 <                        Dim swfeat As SldWorks.Feature
226 <                        swfeat = swEnt
227 <                        N3 = swfeat.Name
222 >            '            '   on se débarasse des arètes qui sont sur une coque ou sur un volume
223 >            '            Dim testArete As Object
224 >            '            testArete = swArete.GetTwoAdjacentFaces2()
225 >
226 >
227 >            '            If testArete(1) Is Nothing And testArete(0) Is Nothing Then 'MsgBox("L'arête est une poutre")
228 >            '                lst_poutres.Add(swEnt)
229 >
230 >            '            ElseIf testArete(1) Is Nothing Then
231 >            '                MsgBox("Une arête sélectionnée appartient à une coque.  Elle ne sera pas prise en compte", MsgBoxStyle.Information)
232 >            '            Else : MsgBox("Une arête sélectionnée appartient à un volume.  Elle ne sera pas prise en compte", MsgBoxStyle.Information)
233 >            '            End If
234 >
235 >            '        Case swSelectType_e.swSelVERTICES, swSelectType_e.swSelSKETCHPOINTS, swSelectType_e.swSelEXTSKETCHPOINTS
236 >            '            obj = SelMgr.GetSelectedObject5(i)
237 >            '            iN3 = i
238 >            '            'N3 = Creation3iemePoint(i, SelMgr) ' attention, ça ça enlève la sélection que l'on a besoin après.
239 >
240 >            '        Case swSelectType_e.swSelCOORDSYS
241 >            '            ' on vient de cliquer sur un système de coordonnées.
242 >            '            swEnt = SelMgr.GetSelectedObject5(i)
243 >            '            Dim swfeat As sldworks.Feature
244 >            '            swfeat = swEnt
245 >            '            N3 = swfeat.Name
246 >
247 >            '        Case Else
248 >            '            MsgBox("Dans AttributPoutre, le select case, type d'entité encore non géré... Ou encore c'est une coque..." & vbCr & "swSelectType_e. = " & SelMgr.GetSelectedObjectType2(i))
249 >            '            ' on avait un truc de trop de sélectionné...
250 >            '    End Select
251 >            'Next i
252  
122                    Case Else
123                        MsgBox("Dans AttributPoutre, le select case, type d'entité encore non géré... Ou encore c'est une coque..." & vbCr & "swSelectType_e. = " & SelMgr.GetSelectedObjectType2(i))
124                        ' on avait un truc de trop de sélectionné...
125                End Select
126            Next i
253  
128            N3 = Creation3iemePoint(iN3, SelMgr)
254  
255              For Each swEnt In lst_poutres
256                  If Not CreationAttributPourPoutre(swEnt, N3) Then GestionAttributPoutre = False : Exit Function
257              Next
133            ' maintenant la création du plan qui visuellement est intéressant...
134
258  
259 +            Return True
260          End Function
261  
262          Private Sub PlanDePoutre(ByRef N3 As String, ByRef poutre As SldWorks.Edge)
# Line 147 | Line 271 | Namespace RealConstant
271          ''' <summary>
272          ''' Function qui créé un repère là où devrait être le troisième point
273          ''' </summary>
150        ''' <param name="i">Le numéro de l'entité sélectionné</param>
151        ''' <param name="selMgr">Le selection manager</param>
274          ''' <returns>Le nom du troisième point</returns>
275          ''' <remarks></remarks>
276 <        Public Function Creation3iemePoint(ByRef i As Long, Optional ByRef selMgr As SldWorks.SelectionMgr = Nothing) As String
276 >        Public Function Creation3iemePoint(ByVal obj As Object) As String '(ByRef i As Long, Optional ByRef selMgr As SldWorks.SelectionMgr = Nothing) As String
277              ' function qui créé le système de coordonné en retournant son nom
278 <            Dim j As Integer
279 <            Dim liste() As Object 'SldWorks.Entity
280 <            Dim swEnt As SldWorks.Entity
278 >            'Dim j As Integer
279 >            'Dim liste() As Object 'SldWorks.Entity
280 >            ' Dim swEnt As sldworks.Entity
281              Static compteur As Long
282  
283  
284 <            If selMgr Is Nothing Then selMgr = swModel.SelectionManager
163 <
164 <            ReDim liste(selMgr.GetSelectedObjectCount)
165 <            For j = 1 To selMgr.GetSelectedObjectCount
166 <                liste(j) = selMgr.GetSelectedObject5(j)
167 <            Next
168 <            Dim ttt As Integer
284 >            'If selMgr Is Nothing Then selMgr = swModel.SelectionManager
285  
286 <            ttt = selMgr.GetSelectedObjectType(i)
286 >            'ReDim liste(selMgr.GetSelectedObjectCount)
287 >            'For j = 1 To selMgr.GetSelectedObjectCount
288 >            'liste(j) = selMgr.GetSelectedObject5(j)
289 >            'Next
290 >            'Dim ttt As Integer
291 >            '
292 >            'ttt = selMgr.GetSelectedObjectType(i)
293              ' pour éviter les maux de têtes, on désélectionne tout, puis on sélectionne juste le point et on y ajoute un syscoord
294 <            If i <> 0 Then
295 <                Select Case selMgr.GetSelectedObjectType(i)
294 >            'If i <> 0 Then
295 >            'Select Case swEnt.GetType 'selMgr.GetSelectedObjectType(i)
296  
297 <                    Case 0
298 <                        MsgBox("Selon Solidworks ... il n'y a rien de sélectionner!")
297 >            '    Case 0
298 >            '        MsgBox("Selon Solidworks ... il n'y a rien de sélectionner!")
299  
300 <                    Case 3
179 <                        swEnt = selMgr.GetSelectedObject(i)
180 <                        swModel.ClearSelection2(True)
181 <                        'swEnt.Select2(False, 1)
182 <                        swEnt.SelectByMark(True, 1)
183 <
184 <
185 <                    Case SwConst.swSelectType_e.swSelEXTSKETCHPOINTS
186 <                        Dim obj As Object
187 <                        selMgr = swModel.SelectionManager
188 <                        obj = selMgr.GetSelectedObject5(i)
189 <                        swModel.ClearSelection2(True)
190 <                        obj.Select2(False, 1) ' faut mettre le mark à 1
191 <                        obj.SelectByMark(True, 1)
192 <                    Case Else
193 <                        MsgBox("Entité inconnue sélectionnée...")
300 >            '    Case 3
301  
302 <                End Select
303 <            End If
302 >            '        swModel.ClearSelection2(True)
303 >            '        'swEnt.Select2(False, 1)
304 >            '        swEnt.SelectByMark(True, 1)
305 >
306 >
307 >            '    Case swconst.swSelectType_e.swSelEXTSKETCHPOINTS
308 >            '        Dim obj As Object
309 >            '        ' selMgr = swModel.SelectionManager
310 >            '        obj = swEnt ' selMgr.GetSelectedObject5(i)
311 >            '        swModel.ClearSelection2(True)
312 >            '        obj.Select2(False, 1) ' faut mettre le mark à 1
313 >            '        obj.SelectByMark(True, 1)
314 >            '    Case Else
315 >            '        MsgBox("Entité inconnue sélectionnée...")
316 >
317 >            'End Select
318 >            'End If
319 >
320 >            Dim swent As sldworks.Entity
321  
322 +            obj.Select2(False, 1) ' faut mettre le mark à 1
323 +            obj.SelectByMark(True, 1)
324              swModel.InsertCoordinateSystem(False, False, False)
325  
326              'swModel.EditRebuild3()
# Line 208 | Line 334 | Namespace RealConstant
334              swModel.ClearSelection2(True)
335  
336              ' on resélectionne tout ce qu'il y a dans la liste
337 <            For j = 1 To UBound(liste)
338 <                liste(j).Select(True)
339 <            Next
337 >            'For j = 1 To UBound(liste)
338 >            'liste(j).Select(True)
339 >            'Next
340  
341  
342              Creation3iemePoint = "Point3#" & compteur
# Line 242 | Line 368 | Namespace RealConstant
368                  mat.sigmay = 150000
369                  lst_mat.Add(mat, mat.nom)
370  
245
246
371                  ' liste des sections de poutres
372                  sec.nom = "S3 x 5.7"
373                  sec.Aire = 1.67 * 0.00064516
# Line 316 | Line 440 | Namespace RealConstant
440                  lst_Section.Add(sec, sec.nom)
441  
442  
443 <                sec.nom = "Tube 2 x 0.5"
443 >                sec.nom = "Tuyau 2 x 0.5"
444                  sec.Aire = 4.34 * 0.00064516
445                  sec.D1 = 2 * 0.0254
446                  sec.D2 = 2 * 0.0254
# Line 364 | Line 488 | Namespace RealConstant
488                  lst_Section.Add(sec, sec.nom)
489  
490  
491 <                sec.nom = "Pipe 3 "
491 >                sec.nom = "Cylindrique (Rod) 3 "
492                  sec.Aire = 1.21 * 0.00064516        ' aléatoire
493                  sec.D1 = 3 * 0.0254                 ' aléatoire
494                  sec.I1 = 1.66 * 0.0000004162364471 ' aléatoire
# Line 392 | Line 516 | Namespace RealConstant
516                  lst_Section.Add(sec, sec.nom)
517  
518  
519 <                sec.nom = " Circulaire pleine générique"
519 >                sec.nom = " Cylindrique (Rod) générique"
520                  sec.Aire = 1
521                  sec.D1 = 0.1
522                  lst_Section.Add(sec, sec.nom)
# Line 520 | Line 644 | Namespace RealConstant
644                  RCNumberboxD6.Value = 0 : LabelD6.Caption = "Innutile"
645                  RCNumberbox5.Value = Aire
646  
647 <            ElseIf ContenuCombo = " Circulaire pleine générique" Then
647 >            ElseIf ContenuCombo = " Cylindrique (Rod) générique" Then
648                  RCCode.InertieCirculairePlein(RCNumberboxD1.Value, Aire, Ixx, Iyy)
649                  RCNumberbox1.Value = Ixx
650                  RCNumberbox2.Value = Iyy
# Line 625 | Line 749 | Namespace RealConstant
749                  RCNumberboxD5.Value = 0 : LabelD5.Caption = "Innutile"
750                  RCNumberboxD6.Value = 0 : LabelD6.Caption = "Innutile"
751                  RCNumberbox5.Value = sec.Aire
752 +            ElseIf Left(ContenuCombo, 2) = "Cy" Then ' circulaire Plein
753 +                RCNumberbox1.Value = sec.I1
754 +                RCNumberbox2.Value = sec.I2
755 +                RCNumberboxD1.Value = sec.D1 : LabelD1.Caption = "Diamètre D1 "
756 +                RCNumberboxD2.Value = 0 : LabelD2.Caption = "Innutile"
757 +                RCNumberboxD3.Value = 0 : LabelD3.Caption = "Innutile"
758 +                RCNumberboxD4.Value = 0 : LabelD4.Caption = "Innutile"
759 +                RCNumberboxD5.Value = 0 : LabelD5.Caption = "Innutile"
760 +                RCNumberboxD6.Value = 0 : LabelD6.Caption = "Innutile"
761 +                RCNumberbox5.Value = sec.Aire
762              ElseIf Left(ContenuCombo, 1) = "C" Then ' le channel
763                  RCNumberbox1.Value = sec.I1
764                  RCNumberbox2.Value = sec.I2
# Line 656 | Line 790 | Namespace RealConstant
790                  RCNumberboxD6.Value = 0 : LabelD6.Caption = "Innutile "
791                  RCNumberbox5.Value = sec.Aire
792  
793 <            ElseIf Left(ContenuCombo, 1) = "P" Then ' circulaire Plein
660 <                RCNumberbox1.Value = sec.I1
661 <                RCNumberbox2.Value = sec.I2
662 <                RCNumberboxD1.Value = sec.D1 : LabelD1.Caption = "Diamètre D1 "
663 <                RCNumberboxD2.Value = 0 : LabelD2.Caption = "Innutile"
664 <                RCNumberboxD3.Value = 0 : LabelD3.Caption = "Innutile"
665 <                RCNumberboxD4.Value = 0 : LabelD4.Caption = "Innutile"
666 <                RCNumberboxD5.Value = 0 : LabelD5.Caption = "Innutile"
667 <                RCNumberboxD6.Value = 0 : LabelD6.Caption = "Innutile"
668 <                RCNumberbox5.Value = sec.Aire
793 >
794              Else
795                  'MsgBox("Le Else est activé dans InfoPoutres, c'est anormal, le type de section n'est pas reconnu!")
796              End If
# Line 687 | Line 812 | Namespace RealConstant
812  
813  
814          Public Function CreationAttributPourPoutre(ByRef swEnt As SldWorks.Entity, ByRef N3 As String, Optional ByRef miniPoutre As Boolean = False) As Boolean
815 +
816              Dim nom As String
817              Dim no As Long 'Static no As Long
818              Dim swArete As SldWorks.Edge
# Line 758 | Line 884 | Namespace RealConstant
884  
885              ' maintenant on place les valeurs.
886              ' Paramètre m:
887 <            Dim m As String
888 <            Dim s As String
889 <            Dim I1 As Double
890 <            Dim I2 As Double
891 <            Dim D1 As Double
892 <            Dim D2 As Double
893 <            Dim D3 As Double
894 <            Dim D4 As Double
895 <            Dim D5 As Double
896 <            Dim D6 As Double
897 <            Dim As1 As Double
898 <            Dim Flag As Double
899 <            If Not miniPoutre Then
900 <                m = RCcombo1.ItemText(RCcombo1.CurrentSelection)
901 <                s = RCcombo2.ItemText(RCcombo2.CurrentSelection)
902 <                I1 = RCNumberbox1.Value
903 <                If I1 <= 0 Then MsgBox("La valeur de l'inertie principale est incorrecte", MsgBoxStyle.Critical, "Une valeur doit être modifiée") : CreationAttributPourPoutre = False : Exit Function
904 <                I2 = RCNumberbox2.Value
905 <                If I2 <= 0 Then MsgBox("La valeur de l'inertie secondaire est incorrecte", MsgBoxStyle.Critical, "Une valeur doit être modifiée") : CreationAttributPourPoutre = False : Exit Function
906 <                D1 = RCNumberboxD1.Value
907 <                If D1 <= 0 Then MsgBox("La valeur de la longueur dans la direction principale (Ixx) est incorrecte", MsgBoxStyle.Critical, "Une valeur doit être modifiée") : CreationAttributPourPoutre = False : Exit Function
908 <                D2 = RCNumberboxD2.Value
909 <                If D2 <= 0 Then MsgBox("La valeur de la longueur dans la direction secondaire (Iyy) est incorrecte", MsgBoxStyle.Critical, "Une valeur doit être modifiée") : CreationAttributPourPoutre = False : Exit Function
910 <
911 <                D3 = RCNumberboxD3.Value
912 <                If D3 <= 0 Then MsgBox("La valeur de la longueur D3 est incorrecte", MsgBoxStyle.Critical, "Une valeur doit être modifiée") : CreationAttributPourPoutre = False : Exit Function
913 <                D4 = RCNumberboxD4.Value
914 <                If D4 <= 0 Then MsgBox("La valeur de la longueur D4) est incorrecte", MsgBoxStyle.Critical, "Une valeur doit être modifiée") : CreationAttributPourPoutre = False : Exit Function
915 <                D5 = RCNumberboxD5.Value
916 <                If D5 <= 0 Then MsgBox("La valeur de la longueur D5 est incorrecte", MsgBoxStyle.Critical, "Une valeur doit être modifiée") : CreationAttributPourPoutre = False : Exit Function
917 <                D6 = RCNumberboxD6.Value
918 <                If D6 <= 0 Then MsgBox("La valeur de la longueur D6) est incorrecte", MsgBoxStyle.Critical, "Une valeur doit être modifiée") : CreationAttributPourPoutre = False : Exit Function
919 <
920 <                As1 = RCNumberbox5.Value
921 <                If As1 <= 0 Then MsgBox("La valeur de l'aide de section est incorrecte", MsgBoxStyle.Critical, "Une valeur doit être modifiée") : CreationAttributPourPoutre = False : Exit Function
922 <
923 <                If RCCode.RCCheckFacedeSection.Checked = True Then Flag = 1 Else Flag = 0
924 <
925 <
926 <            Else
927 <                'mettre ici les valeurs pour les mini-poutres
928 <                m = "Materiau"
929 <                s = "Section"
930 <                I1 = 22
931 <                I2 = 22
932 <                D1 = 22
933 <                D2 = 22
934 <                As1 = 22
935 <                Flag = 0
936 <            End If
937 <
938 <
813 <
887 >            'Dim m As String
888 >            'Dim s As String
889 >            'Dim I1 As Double
890 >            'Dim I2 As Double
891 >            'Dim D1 As Double
892 >            'Dim D2 As Double
893 >            'Dim D3 As Double
894 >            'Dim D4 As Double
895 >            'Dim D5 As Double
896 >            'Dim D6 As Double
897 >            'Dim As1 As Double
898 >            'Dim Flag As Double
899 >            'If Not miniPoutre Then
900 >            '    m = RCcombo1.ItemText(RCcombo1.CurrentSelection)
901 >            '    s = RCcombo2.ItemText(RCcombo2.CurrentSelection)
902 >            '    I1 = RCNumberbox1.Value
903 >            '    If I1 <= 0 Then MsgBox("La valeur de l'inertie principale est incorrecte", MsgBoxStyle.Critical, "Une valeur doit être modifiée") : CreationAttributPourPoutre = False : Exit Function
904 >            '    I2 = RCNumberbox2.Value
905 >            '    If I2 <= 0 Then MsgBox("La valeur de l'inertie secondaire est incorrecte", MsgBoxStyle.Critical, "Une valeur doit être modifiée") : CreationAttributPourPoutre = False : Exit Function
906 >            '    D1 = RCNumberboxD1.Value
907 >            '    If D1 <= 0 Then MsgBox("La valeur de la longueur dans la direction principale (Ixx) est incorrecte", MsgBoxStyle.Critical, "Une valeur doit être modifiée") : CreationAttributPourPoutre = False : Exit Function
908 >            '    D2 = RCNumberboxD2.Value
909 >            '    If D2 <= 0 Then MsgBox("La valeur de la longueur dans la direction secondaire (Iyy) est incorrecte", MsgBoxStyle.Critical, "Une valeur doit être modifiée") : CreationAttributPourPoutre = False : Exit Function
910 >
911 >            '    D3 = RCNumberboxD3.Value
912 >            '    If D3 <= 0 Then MsgBox("La valeur de la longueur D3 est incorrecte", MsgBoxStyle.Critical, "Une valeur doit être modifiée") : CreationAttributPourPoutre = False : Exit Function
913 >            '    D4 = RCNumberboxD4.Value
914 >            '    If D4 <= 0 Then MsgBox("La valeur de la longueur D4) est incorrecte", MsgBoxStyle.Critical, "Une valeur doit être modifiée") : CreationAttributPourPoutre = False : Exit Function
915 >            '    D5 = RCNumberboxD5.Value
916 >            '    If D5 <= 0 Then MsgBox("La valeur de la longueur D5 est incorrecte", MsgBoxStyle.Critical, "Une valeur doit être modifiée") : CreationAttributPourPoutre = False : Exit Function
917 >            '    D6 = RCNumberboxD6.Value
918 >            '    If D6 <= 0 Then MsgBox("La valeur de la longueur D6) est incorrecte", MsgBoxStyle.Critical, "Une valeur doit être modifiée") : CreationAttributPourPoutre = False : Exit Function
919 >
920 >            '    As1 = RCNumberbox5.Value
921 >            '    If As1 <= 0 Then MsgBox("La valeur de l'aide de section est incorrecte", MsgBoxStyle.Critical, "Une valeur doit être modifiée") : CreationAttributPourPoutre = False : Exit Function
922 >
923 >            '    If RCCode.FaceDeSectionPoutre = True Then Flag = 1 Else Flag = 0
924 >
925 >
926 >            'Else
927 >            '    'mettre ici les valeurs pour les mini-poutres
928 >            '    m = "Materiau"
929 >            '    s = "Section"
930 >            '    I1 = 22
931 >            '    I2 = 22
932 >            '    D1 = 22
933 >            '    D2 = 22
934 >            '    As1 = 22
935 >            '    Flag = 0
936 >            'End If
937 >            If FaceDeSectionPoutre = True Then Flag = 1 Else Flag = 0
938 >            If miniPoutre = True Then As1 = -7
939              ParamM.SetStringValue2(m, 2, "")  ' swAllConfiguration = 2
940              ParamS.SetStringValue2(s, 2, "")
941              ParamI1.SetDoubleValue2(I1, 2, "")
# Line 825 | Line 950 | Namespace RealConstant
950              ParamD6.SetDoubleValue2(D6, 2, "")
951              ParamAs.SetDoubleValue2(As1, 2, "")
952              ParamFlag.SetDoubleValue2(Flag, 2, "")
953 +
954              If As1 < Commun.Amax Then Commun.Amax = As1
955              If Not miniPoutre Then ParamN3.SetStringValue2(N3, 2, "")
956  
957 +
958              'swModel.Extension.SelectByID2(nom, "ATTRIBUTE", 0, 0, 0, False, 0, Nothing, 0)
959  
960 +            'Try
961 +            'swModel.EditRebuild3()
962 +            'Dim swFeat As sldworks.Feature = swModel.FeatureByPositionReverse(0)
963 +            'Dim chaine As String
964 +            'chaine = "Section = " & CStr(s) & vbCr & "Ixx = " & Format(I1, "0.000E+00") & " m^4" & vbCr & "Iyy = " & Format(I2, "0.000E+00") & " m^4" & vbCr & "Aire section = " & Format(As1, "0.000E+00") & " m^2" & vbCr & "D1 = " & Format(D1, "0.000E+00") & " m" & vbCr & "D2 = " & Format(D2, "0.000E+00") & " m" & vbCr & "D3 = " & Format(D3, "0.000E+00") & " m" & vbCr & "D4 = " & Format(D4, "0.000E+00") & " m" & vbCr & "D5 = " & Format(D5, "0.000E+00") & " m" & vbCr & "D6 = " & Format(D6, "0.000E+00") & " m"
965 +            'Debug.Print(chaine)
966 +            'swFeat.AddComment(chaine)
967 +            'Catch ex As Exception
968 +
969 +            'End Try
970  
971              GererDossiers("Poutres", nom)
972  
973 <            no = no + 1
973 >
974              If miniPoutre Then swArete.Display(2, 1, 0, 1, True) Else swArete.Display(2, 0, 1, 0, True) ' mini-poutre = violet, poutre = vert
975  
976  
# Line 842 | Line 979 | Namespace RealConstant
979  
980          Private Function GestionAttributCoque() As Boolean
981              Dim swFace As SldWorks.Face2
982 <            Dim i As Integer
846 <            Dim coques() As SldWorks.Entity
847 <            ReDim coques(0)
848 <
982 >            Dim coques As New Collections.Generic.List(Of sldworks.Entity)
983  
984 <            Dim SelMgr As SldWorks.SelectionMgr
984 >            Dim SelMgr As sldworks.SelectionMgr
985              Dim swEnt As SldWorks.Entity
986              SelMgr = swModel.SelectionManager
987  
988 <            If RCselection3.ItemCount = 0 Then MsgBox("Vous devez sélectionner au moins une face (coque)!", MsgBoxStyle.Critical, "Impossible d'exécuter la commande") : Exit Function
988 >            If lstSelection3.Count = 0 Then MsgBox("Vous devez sélectionner au moins une face (coque)!", MsgBoxStyle.Critical, "Impossible d'exécuter la commande") : Exit Function
989  
990              ' dans les entités sélectionnées il y a des faces.
991  
992 <            For i = 1 To SelMgr.GetSelectedObjectCount
993 <
994 <                swEnt = SelMgr.GetSelectedObject5(i)
992 >            'For i = 1 To SelMgr.GetSelectedObjectCount
993 >            For Each swEnt In lstSelection3
994 >                'swEnt = SelMgr.GetSelectedObject5(i)
995                  swFace = swEnt
996  
997                  '   on se débarasse des faces qui sont sur un volume
998 <                Dim corps As SldWorks.Body2
998 >                Dim corps As sldworks.Body2
999  
1000                  corps = swFace.GetBody()
1001  
1002 <                If Not corps.GetType = SwConst.swBodyType_e.swSolidBody Then
1003 <                    If Not UBound(coques) = 0 Then ReDim Preserve coques(UBound(coques, 1) + 1)
870 <                    coques(UBound(coques)) = swEnt
1002 >                If Not corps.GetType = swconst.swBodyType_e.swSolidBody Then
1003 >                    coques.Add(swEnt)
1004                      'If Not CreationAttributPourCoque(swEnt) Then GestionAttributCoque = False : Exit Function
1005                  Else
1006                      MsgBox("Une face sélectionnée appartient à un volume, elle ne sera pas traitée!", MsgBoxStyle.Information, "Une face n'est pas une coque")
1007                  End If
1008 <            Next i
1008 >            Next swEnt
1009  
1010 <            For i = 0 To UBound(coques)
1011 <                CreationAttributPourCoque(coques(i))
1010 >            For Each swEnt In coques
1011 >                CreationAttributPourCoque(swEnt)
1012              Next
1013 <
1013 >            Return True
1014  
1015          End Function
1016  
# Line 913 | Line 1046 | Namespace RealConstant
1046  
1047              ' maintenant on place les valeurs.
1048              ' Paramètre m:
1049 <            If materiau Is Nothing Then materiau = RCcombo1.ItemText(RCcombo3.CurrentSelection)
1050 <            If Epaisseur = -1 Then Epaisseur = RCNumberbox6.Value
1049 >            'If materiau Is Nothing Then materiau = RCcombo1.ItemText(RCcombo3.CurrentSelection)
1050 >            If Epaisseur = -1 Then Epaisseur = ModEpaisseur 'RCNumberbox6.Value '
1051              If Epaisseur <= 0 Then MsgBox("La valeur de l'épaisseur de la coque est nulle ou inférieure à 0, veillez modifier cette valeur", MsgBoxStyle.Critical, "Une valeur doit être modifiée") : CreationAttributPourCoque = False : Exit Function
1052              If RCCode.RCCheckFacedeSectionCoque.Checked = True Then Flag = 1 Else Flag = 0
1053 +            If FaceDeSectionCoque Then Flag = 1 Else Flag = 0
1054  
1055              ParamM.SetStringValue2(materiau, 2, "")  ' swAllConfiguration = 2
1056              ParamEp.SetDoubleValue2(Epaisseur, 2, "")
1057              ParamFlag.SetDoubleValue2(Flag, 2, "")
1058  
1059 +
1060 +            Try
1061 +                swModel.EditRebuild3()
1062 +                Dim swFeat As sldworks.Feature = swModel.FeatureByPositionReverse(0)
1063 +                Dim chaine As String
1064 +                chaine = "Épaisseur = " & Format(Epaisseur, "0.00000") & " m" & vbCr & "Flag (pour débug) " & Format(Flag, "0")
1065 +                swFeat.AddComment(chaine)
1066 +            Catch ex As Exception
1067 +
1068 +            End Try
1069 +
1070              GererDossiers("Coques", nom)
1071  
1072  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines