| 1 |
bournival |
48 |
Imports SolidWorks.Interop
|
| 2 |
|
|
Imports SolidWorks.Interop.swconst
|
| 3 |
|
|
Imports SolidWorks.Interop.swpublished
|
| 4 |
|
|
|
| 5 |
bournival |
40 |
Module Intersections
|
| 6 |
|
|
Public DefAttrInterALAL As SldWorks.AttributeDef
|
| 7 |
|
|
Public DefAttrConditionLimite As SldWorks.AttributeDef
|
| 8 |
|
|
Public DefAttrRCP1 As SldWorks.AttributeDef
|
| 9 |
|
|
Public DefAttrRCCoque As SldWorks.AttributeDef
|
| 10 |
|
|
Public DefAttrFaceInterne As SldWorks.AttributeDef
|
| 11 |
|
|
Public DefAttrDoublon As SldWorks.AttributeDef
|
| 12 |
|
|
Public DefAttrIgnorer As SldWorks.AttributeDef
|
| 13 |
|
|
|
| 14 |
|
|
Public nbMinipoutre As Long
|
| 15 |
|
|
|
| 16 |
|
|
|
| 17 |
|
|
|
| 18 |
|
|
#Region "Enums"
|
| 19 |
|
|
Public Enum typeInterPoutreVolume
|
| 20 |
|
|
Centre = 0
|
| 21 |
|
|
Sur_arete = 1
|
| 22 |
|
|
Sur_sommet = 2
|
| 23 |
|
|
Courbe = 3
|
| 24 |
|
|
End Enum
|
| 25 |
|
|
|
| 26 |
|
|
#End Region
|
| 27 |
|
|
|
| 28 |
|
|
|
| 29 |
|
|
Public Sub Debuter(Optional ByRef nom2 As String = "C:\Documents and Settings\Sylvain Bournival\Bureau\testMAGiC.sldprt", Optional ByVal nomFichier As String = "", Optional ByRef original As Boolean = True, Optional ByRef modifie As Boolean = True)
|
| 30 |
|
|
|
| 31 |
|
|
' *******
|
| 32 |
|
|
' quelques options de performance
|
| 33 |
|
|
' *******
|
| 34 |
bournival |
48 |
swApp.SetUserPreferenceIntegerValue(swconst.swUserPreferenceIntegerValue_e.swAutoSaveInterval, 0)
|
| 35 |
bournival |
40 |
swModel.SetAddToDB(True)
|
| 36 |
|
|
swModel.SetDisplayWhenAdded(False)
|
| 37 |
|
|
' ******
|
| 38 |
|
|
' fin des options de performance
|
| 39 |
|
|
' ******
|
| 40 |
|
|
|
| 41 |
|
|
Memoriser3iemePoint() ' mémorise le coord system car si on découpe, sa coordonnée est perdue.
|
| 42 |
|
|
CouperPoutres()
|
| 43 |
|
|
Commun.GenererListes() ' va ignorer les poutres à ignorer... et ajouter les poutres coupées dans la liste.
|
| 44 |
|
|
|
| 45 |
|
|
|
| 46 |
|
|
|
| 47 |
|
|
' Traitement des intersection poutres-Volumes
|
| 48 |
|
|
DetectionPoutresVolumes()
|
| 49 |
|
|
DecouperPoutreVolume()
|
| 50 |
|
|
' fin traitement intersection poutres-volumes
|
| 51 |
|
|
|
| 52 |
|
|
swModel.EditRebuild3()
|
| 53 |
|
|
|
| 54 |
|
|
|
| 55 |
|
|
|
| 56 |
|
|
' Traitement des intersection entre poutre et coques
|
| 57 |
|
|
DetectionPoutresCoques()
|
| 58 |
|
|
DecouperPoutreCoque()
|
| 59 |
|
|
' Fin du traitement des intersections entre poutre et coques
|
| 60 |
|
|
|
| 61 |
|
|
|
| 62 |
|
|
' traitement des coques-volumes
|
| 63 |
|
|
DetectionCoqueVolume()
|
| 64 |
|
|
DécouperCoqueVolume()
|
| 65 |
|
|
' fin traitement coque volume
|
| 66 |
|
|
|
| 67 |
|
|
' traitement des coques-coques
|
| 68 |
|
|
DetectionCoqueCoque()
|
| 69 |
bournival |
46 |
DecouperCoqueCoque()
|
| 70 |
bournival |
40 |
'
|
| 71 |
|
|
|
| 72 |
|
|
|
| 73 |
|
|
|
| 74 |
|
|
' *******
|
| 75 |
|
|
' quelques options de performance, remettre à la position initiale
|
| 76 |
|
|
' *******
|
| 77 |
bournival |
48 |
swApp.SetUserPreferenceIntegerValue(swconst.swUserPreferenceIntegerValue_e.swAutoSaveInterval, 15)
|
| 78 |
bournival |
40 |
swModel.SetAddToDB(False)
|
| 79 |
|
|
swModel.SetDisplayWhenAdded(True)
|
| 80 |
|
|
swModel.GraphicsRedraw2()
|
| 81 |
|
|
' ******
|
| 82 |
|
|
' fin des options de performance
|
| 83 |
|
|
' ******
|
| 84 |
|
|
ReplacerFolder()
|
| 85 |
|
|
|
| 86 |
|
|
|
| 87 |
|
|
End Sub
|
| 88 |
|
|
|
| 89 |
|
|
|
| 90 |
|
|
''' <summary>
|
| 91 |
bournival |
46 |
''' Sub qui découpe les coques en fonction des informations placées dans le InterCoqueCoque
|
| 92 |
|
|
''' </summary>
|
| 93 |
|
|
''' <remarks></remarks>
|
| 94 |
|
|
Private Sub DecouperCoqueCoque()
|
| 95 |
|
|
Dim rayon As Double
|
| 96 |
|
|
|
| 97 |
|
|
|
| 98 |
|
|
For Each Coque As SlyFaceCoque In Commun.lst_FaceCoque
|
| 99 |
|
|
For Each interCC As InterCoqueCoque In Coque.lst_InterCoqueCoque
|
| 100 |
|
|
rayon = IIf(Coque Is interCC.sFaceCoque1, interCC.sFaceCoque2.GetEpaisseur, interCC.sFaceCoque1.GetEpaisseur)
|
| 101 |
|
|
Dim sweep As SldWorks.Body2 = interCC.GénérerSweep(interCC.sketch, rayon)
|
| 102 |
|
|
interCC.DecouperCoque(Coque, sweep)
|
| 103 |
|
|
|
| 104 |
|
|
' reste à retrouver les faces internes.
|
| 105 |
|
|
interCC.MarquerFacesInternes(IIf(Coque Is interCC.sFaceCoque1, interCC.sFaceCoque2, interCC.sFaceCoque1), IIf(Coque Is interCC.sFaceCoque1, interCC.sFaceCoque1, interCC.sFaceCoque2))
|
| 106 |
|
|
Next
|
| 107 |
|
|
Next
|
| 108 |
|
|
|
| 109 |
|
|
|
| 110 |
|
|
End Sub
|
| 111 |
|
|
|
| 112 |
|
|
''' <summary>
|
| 113 |
bournival |
40 |
''' sub qui créé une instance de la classe interCoqueCoque s'il y a une intersection de ce type
|
| 114 |
|
|
''' </summary>
|
| 115 |
|
|
''' <remarks></remarks>
|
| 116 |
|
|
Private Sub DetectionCoqueCoque()
|
| 117 |
|
|
|
| 118 |
|
|
Dim sketch As SldWorks.Sketch = Nothing
|
| 119 |
|
|
Dim interCC As InterCoqueCoque = Nothing
|
| 120 |
bournival |
46 |
Dim Coque1 As SlyFaceCoque, Coque2 As SlyFaceCoque
|
| 121 |
bournival |
40 |
|
| 122 |
bournival |
46 |
For i As Integer = 0 To Commun.lst_FaceCoque.Count - 2 'For Each Coque1 As SlyFaceCoque In Commun.lst_FaceCoque
|
| 123 |
|
|
Coque1 = Commun.lst_FaceCoque.Item(i)
|
| 124 |
|
|
For j As Integer = i + 1 To Commun.lst_FaceCoque.Count - 1 ' For Each coque2 As SlyFaceCoque In lst_FaceCoque
|
| 125 |
|
|
Coque2 = Commun.lst_FaceCoque.Item(j)
|
| 126 |
|
|
If DetectFaceFace(Coque2.SwFace, Coque1.SwFace, True, sketch) Then
|
| 127 |
bournival |
40 |
' création de l'instance de interFace-face entre coque et coque
|
| 128 |
|
|
|
| 129 |
|
|
interCC = New InterCoqueCoque
|
| 130 |
|
|
interCC.sFaceCoque1 = Coque1
|
| 131 |
bournival |
46 |
interCC.sFaceCoque2 = Coque2
|
| 132 |
bournival |
40 |
interCC.FaceDeSection = False
|
| 133 |
|
|
interCC.sketch = sketch
|
| 134 |
|
|
|
| 135 |
|
|
Coque1.lst_InterCoqueCoque.Add(interCC)
|
| 136 |
bournival |
46 |
Coque2.lst_InterCoqueCoque.Add(interCC)
|
| 137 |
bournival |
40 |
End If
|
| 138 |
|
|
|
| 139 |
bournival |
46 |
Next j
|
| 140 |
|
|
Next i
|
| 141 |
bournival |
40 |
|
| 142 |
|
|
End Sub
|
| 143 |
|
|
|
| 144 |
|
|
|
| 145 |
|
|
Private Sub ReplacerFolder()
|
| 146 |
|
|
' on doit mettre les folders à la fin pour que ça marche dans MAGiC
|
| 147 |
|
|
'Si on ne met pas les attributs à la fin on est baisé...
|
| 148 |
|
|
|
| 149 |
|
|
Dim swFeat As SldWorks.Feature = Nothing
|
| 150 |
|
|
Dim nomdernier As String
|
| 151 |
|
|
Dim dansFolder As Boolean = False
|
| 152 |
|
|
Dim i As Integer = 0
|
| 153 |
|
|
Dim ok As Boolean = False
|
| 154 |
|
|
Dim SelMgr As SldWorks.SelectionMgr
|
| 155 |
|
|
|
| 156 |
|
|
'trouver le premier feature qui n'est pas un folder...
|
| 157 |
|
|
Do Until ok
|
| 158 |
|
|
swFeat = swModel.FeatureByPositionReverse(i)
|
| 159 |
|
|
nomdernier = swFeat.GetTypeName
|
| 160 |
|
|
|
| 161 |
|
|
If (nomdernier = "FtrFolder") Then
|
| 162 |
|
|
dansFolder = Not dansFolder
|
| 163 |
|
|
Else
|
| 164 |
|
|
If Not dansFolder Then ok = True
|
| 165 |
|
|
End If
|
| 166 |
|
|
i += 1
|
| 167 |
|
|
Loop
|
| 168 |
|
|
|
| 169 |
|
|
nomdernier = swFeat.Name
|
| 170 |
|
|
|
| 171 |
|
|
SelMgr = swModel.SelectionManager
|
| 172 |
|
|
If swModel.Extension.SelectByID2("Poutres", "FTRFOLDER", 0, 0, 0, False, 0, Nothing, 0) Then swModel.ReorderFeature("Poutres", nomdernier)
|
| 173 |
|
|
If swModel.Extension.SelectByID2("Coques", "FTRFOLDER", 0, 0, 0, False, 0, Nothing, 0) Then swModel.ReorderFeature("Coques", nomdernier)
|
| 174 |
|
|
If swModel.Extension.SelectByID2("Conditions Aux Limites", "FTRFOLDER", 0, 0, 0, False, 0, Nothing, 0) Then swModel.ReorderFeature("Conditions Aux Limites", nomdernier)
|
| 175 |
|
|
If swModel.Extension.SelectByID2("FaceInternes", "FTRFOLDER", 0, 0, 0, False, 0, Nothing, 0) Then swModel.ReorderFeature("FaceInternes", nomdernier)
|
| 176 |
|
|
|
| 177 |
|
|
End Sub
|
| 178 |
|
|
|
| 179 |
|
|
|
| 180 |
|
|
Public Sub RegisterAttribut()
|
| 181 |
|
|
Static nouveau As Boolean
|
| 182 |
|
|
'propriétés des intersections entre 2 poutres (Arete-libre Arête-libre)
|
| 183 |
|
|
|
| 184 |
|
|
If nouveau Then Exit Sub
|
| 185 |
|
|
Dim nom As String
|
| 186 |
|
|
Dim retval As Boolean
|
| 187 |
|
|
|
| 188 |
|
|
nom = "InterALAL"
|
| 189 |
|
|
DefAttrInterALAL = swApp.DefineAttribute(nom)
|
| 190 |
bournival |
48 |
DefAttrInterALAL.AddParameter("X", swconst.swParamType_e.swParamTypeDouble, 0, 0)
|
| 191 |
|
|
DefAttrInterALAL.AddParameter("Y", swconst.swParamType_e.swParamTypeDouble, 0, 0)
|
| 192 |
|
|
DefAttrInterALAL.AddParameter("Z", swconst.swParamType_e.swParamTypeDouble, 0, 0)
|
| 193 |
|
|
DefAttrInterALAL.AddParameter("T", swconst.swParamType_e.swParamTypeDouble, -1, 0)
|
| 194 |
bournival |
40 |
retval = DefAttrInterALAL.Register()
|
| 195 |
|
|
If retval = False Then MsgBox("Enregistrement raté pour le InterALAL")
|
| 196 |
|
|
|
| 197 |
|
|
|
| 198 |
|
|
nom = "ConditionLimite"
|
| 199 |
|
|
DefAttrConditionLimite = swApp.DefineAttribute(nom)
|
| 200 |
bournival |
48 |
DefAttrConditionLimite.AddParameter("CL", swconst.swParamType_e.swParamTypeString, 0, 0)
|
| 201 |
bournival |
40 |
retval = DefAttrConditionLimite.Register()
|
| 202 |
|
|
If retval = False Then MsgBox("Enregistrement raté pour le COndition Limite")
|
| 203 |
|
|
|
| 204 |
|
|
|
| 205 |
|
|
DefAttrRCP1 = swApp.DefineAttribute("Poutre1")
|
| 206 |
|
|
DefAttrRCP1.AddParameter("M", 1, 0, 0) ' 0 = double, 1 = string, 2 = integer
|
| 207 |
|
|
DefAttrRCP1.AddParameter("S", 1, 0, 0)
|
| 208 |
|
|
DefAttrRCP1.AddParameter("As", 0, 0, 0)
|
| 209 |
|
|
DefAttrRCP1.AddParameter("I1", 0, 0, 0)
|
| 210 |
|
|
DefAttrRCP1.AddParameter("I2", 0, 0, 0)
|
| 211 |
|
|
DefAttrRCP1.AddParameter("N3", 1, 0, 0) ' le nom du troisième point
|
| 212 |
|
|
DefAttrRCP1.AddParameter("X3", 0, 0, 0) ' le x du troisième point
|
| 213 |
|
|
DefAttrRCP1.AddParameter("Y3", 0, 0, 0) ' le y du troisième point
|
| 214 |
|
|
DefAttrRCP1.AddParameter("Z3", 0, 0, 0) ' le z du troisième point
|
| 215 |
|
|
DefAttrRCP1.AddParameter("D1", 0, 0, 0)
|
| 216 |
|
|
DefAttrRCP1.AddParameter("D2", 0, 0, 0)
|
| 217 |
|
|
DefAttrRCP1.AddParameter("D3", 0, 0, 0)
|
| 218 |
|
|
DefAttrRCP1.AddParameter("D4", 0, 0, 0)
|
| 219 |
|
|
DefAttrRCP1.AddParameter("D5", 0, 0, 0)
|
| 220 |
|
|
DefAttrRCP1.AddParameter("D6", 0, 0, 0)
|
| 221 |
|
|
DefAttrRCP1.AddParameter("Flag", 0, 0, 0)
|
| 222 |
|
|
|
| 223 |
|
|
retval = DefAttrRCP1.Register()
|
| 224 |
|
|
If retval = False Then MsgBox("Enregistrement raté pour le RCPoutre")
|
| 225 |
|
|
|
| 226 |
|
|
DefAttrRCCoque = swApp.DefineAttribute("Coque")
|
| 227 |
|
|
DefAttrRCCoque.AddParameter("M", 1, 0, 0) 'le matériau' 0 = double, 1 = string, 2 = integer
|
| 228 |
|
|
DefAttrRCCoque.AddParameter("Ep", 0, 0, 0) ' épaisseur
|
| 229 |
|
|
DefAttrRCCoque.AddParameter("Flag", 0, 0, 0) ' un flag pour les coques...
|
| 230 |
|
|
retval = DefAttrRCCoque.Register()
|
| 231 |
|
|
If retval = False Then MsgBox("Enregistrement raté pour le RCCoque")
|
| 232 |
|
|
|
| 233 |
|
|
DefAttrFaceInterne = swApp.DefineAttribute("FaceInterne")
|
| 234 |
|
|
DefAttrFaceInterne.AddParameter("FI", 0, 0, 0) ' la présence de l'attribut est suffisante.
|
| 235 |
|
|
retval = DefAttrFaceInterne.Register()
|
| 236 |
|
|
If retval = False Then MsgBox("Enregistrement raté pour le FaceInterne")
|
| 237 |
|
|
|
| 238 |
|
|
DefAttrDoublon = swApp.DefineAttribute("Doublon")
|
| 239 |
|
|
DefAttrDoublon.AddParameter("Maitre", 1, 0, 0) ' le nom du maitre...
|
| 240 |
|
|
DefAttrDoublon.AddParameter("Sens", 0, 0, 0) ' -1 si dans le sens oposé
|
| 241 |
|
|
retval = DefAttrDoublon.Register()
|
| 242 |
|
|
If retval = False Then MsgBox("Enregistrement raté pour le Doublon")
|
| 243 |
|
|
|
| 244 |
|
|
nom = "Ignorer"
|
| 245 |
|
|
DefAttrIgnorer = swApp.DefineAttribute(nom)
|
| 246 |
|
|
DefAttrIgnorer.AddParameter("Rien", 0, 0, 0)
|
| 247 |
|
|
retval = DefAttrIgnorer.Register()
|
| 248 |
|
|
If retval = False Then MsgBox("Enregistrement raté pour le Ignorer")
|
| 249 |
|
|
|
| 250 |
|
|
nouveau = True
|
| 251 |
|
|
|
| 252 |
|
|
End Sub
|
| 253 |
|
|
|
| 254 |
|
|
Private Sub TraiteAPAP()
|
| 255 |
|
|
' procédure plus utilisée.
|
| 256 |
|
|
' procédure qui trouve les intersections entre les poutres et qui créé un attribut contenant les informations
|
| 257 |
|
|
|
| 258 |
|
|
' en premier on efface les features attributs, pour ne pas avoir de doubles
|
| 259 |
|
|
Dim feat As SldWorks.Feature
|
| 260 |
|
|
feat = swPart.FirstFeature
|
| 261 |
|
|
Dim nextfeat As SldWorks.Feature
|
| 262 |
|
|
|
| 263 |
|
|
Do While Not feat Is Nothing
|
| 264 |
|
|
If Left(feat.Name, 9) = "InterAPAP" Then
|
| 265 |
|
|
nextfeat = feat.GetNextFeature
|
| 266 |
|
|
swModel.Extension.SelectByID2(feat.Name, "ATTRIBUTE", 0, 0, 0, False, 0, Nothing, 0)
|
| 267 |
|
|
swPart.EditDelete()
|
| 268 |
|
|
feat = nextfeat
|
| 269 |
|
|
Else
|
| 270 |
|
|
feat = feat.GetNextFeature
|
| 271 |
|
|
End If
|
| 272 |
|
|
Loop
|
| 273 |
|
|
' faut aussi détruire les liste de points dans les poutres
|
| 274 |
|
|
' ce qui suit n'est pas optimisé en temps d'exécution, mais en temps de programmation ;-)
|
| 275 |
|
|
' j'aurais besoin d'un trouver qui retourne le sly... en fonction d'un feature(edge)
|
| 276 |
|
|
Dim p As SlyAretePoutre
|
| 277 |
|
|
For Each p In lst_AretePoutre
|
| 278 |
|
|
p.EffacerIntersection()
|
| 279 |
|
|
Next
|
| 280 |
|
|
|
| 281 |
|
|
|
| 282 |
|
|
' ' fin de l'effacement des attributs
|
| 283 |
|
|
Dim swArete1 As SldWorks.Edge
|
| 284 |
|
|
Dim swArete2 As SldWorks.Edge
|
| 285 |
|
|
Dim SlyArete1 As SlyAretePoutre
|
| 286 |
|
|
Dim SlyArete2 As SlyAretePoutre
|
| 287 |
|
|
|
| 288 |
|
|
Dim xyz() As Double = Nothing
|
| 289 |
|
|
Dim pt As New InterPoutrePoutre
|
| 290 |
|
|
'Dim lst_pts As New Collection
|
| 291 |
|
|
Dim i As Long
|
| 292 |
|
|
|
| 293 |
|
|
Dim a1 As Integer
|
| 294 |
|
|
Dim a2 As Integer
|
| 295 |
|
|
|
| 296 |
|
|
|
| 297 |
|
|
For a1 = 0 To lst_AretePoutre.Count - 2
|
| 298 |
|
|
SlyArete1 = lst_AretePoutre.Item(a1)
|
| 299 |
|
|
swArete1 = SlyArete1.swArete
|
| 300 |
|
|
|
| 301 |
|
|
For a2 = a1 + 1 To lst_AretePoutre.Count - 1
|
| 302 |
|
|
SlyArete2 = lst_AretePoutre.Item(a2)
|
| 303 |
|
|
swArete2 = SlyArete2.swArete
|
| 304 |
|
|
|
| 305 |
|
|
If DetectAreteArete(swArete1, swArete2, xyz) Then ' intersection courbe-courbe
|
| 306 |
|
|
For i = 0 To CInt((UBound(xyz) + 1) / 4) Step 4 ' si y'a plus d'une intersection entre les 2 courbes...
|
| 307 |
|
|
|
| 308 |
|
|
Select Case isIntersect_milieu(swArete1, swArete2, xyz(i), xyz(i + 1), xyz(i + 2))
|
| 309 |
|
|
Case 1 ' la première courbe est coupée
|
| 310 |
|
|
pt = New InterPoutrePoutre
|
| 311 |
|
|
pt.Arete = swArete1
|
| 312 |
|
|
pt.x = xyz(i) : pt.y = xyz(i + 1) : pt.z = xyz(i + 2)
|
| 313 |
|
|
SlyArete1.AjouterPointAPAP(pt)
|
| 314 |
|
|
pt = Nothing
|
| 315 |
|
|
Case 2 ' la seconde courbe est coupée
|
| 316 |
|
|
pt = New InterPoutrePoutre
|
| 317 |
|
|
pt.Arete = swArete2
|
| 318 |
|
|
pt.x = xyz(i) : pt.y = xyz(i + 1) : pt.z = xyz(i + 2)
|
| 319 |
|
|
SlyArete2.AjouterPointAPAP(pt)
|
| 320 |
|
|
pt = Nothing
|
| 321 |
|
|
Case 3 ' les doux courbes sont coupées
|
| 322 |
|
|
pt = New InterPoutrePoutre
|
| 323 |
|
|
pt.Arete = swArete1
|
| 324 |
|
|
pt.x = xyz(i) : pt.y = xyz(i + 1) : pt.z = xyz(i + 2)
|
| 325 |
|
|
SlyArete1.AjouterPointAPAP(pt)
|
| 326 |
|
|
pt = Nothing
|
| 327 |
|
|
pt = New InterPoutrePoutre
|
| 328 |
|
|
pt.Arete = swArete2
|
| 329 |
|
|
pt.x = xyz(i) : pt.y = xyz(i + 1) : pt.z = xyz(i + 2)
|
| 330 |
|
|
SlyArete2.AjouterPointAPAP(pt)
|
| 331 |
|
|
pt = Nothing
|
| 332 |
|
|
End Select
|
| 333 |
|
|
Next i
|
| 334 |
|
|
End If
|
| 335 |
|
|
|
| 336 |
|
|
Next a2
|
| 337 |
|
|
Next a1
|
| 338 |
|
|
pt = Nothing
|
| 339 |
|
|
End Sub
|
| 340 |
|
|
|
| 341 |
|
|
|
| 342 |
|
|
Public Function DetectAreteArete(ByRef swArete1 As SldWorks.Edge, ByRef swArete2 As SldWorks.Edge, ByRef xyz() As Double) As Boolean
|
| 343 |
|
|
' function qui détermine si 2 arêtes se touchent, si oui alors la fonction retourne vrai et le tableau XYZ contient le point d'intersection
|
| 344 |
|
|
xyz = Nothing
|
| 345 |
|
|
If swArete2 Is Nothing Then Exit Function
|
| 346 |
|
|
If swArete1 Is Nothing Then Exit Function
|
| 347 |
|
|
|
| 348 |
|
|
Dim swSommet As SldWorks.Vertex
|
| 349 |
|
|
Dim point1 As Object ' point début courbe 1
|
| 350 |
|
|
Dim point2 As Object ' point fin, courbe 1
|
| 351 |
|
|
Dim point3 As Object ' point début courbe 2
|
| 352 |
|
|
Dim point4 As Object ' point fin, courbe 2
|
| 353 |
|
|
Dim swCourbe1 As SldWorks.Curve
|
| 354 |
|
|
Dim swCourbe2 As SldWorks.Curve
|
| 355 |
|
|
Dim vIntersectPts As Object
|
| 356 |
|
|
|
| 357 |
|
|
swSommet = swArete1.GetStartVertex
|
| 358 |
|
|
If swSommet Is Nothing Then ' cercle fermé
|
| 359 |
|
|
point1 = swArete1.Evaluate(0)
|
| 360 |
|
|
point2 = point1
|
| 361 |
|
|
Else
|
| 362 |
|
|
point1 = swSommet.GetPoint
|
| 363 |
|
|
swSommet = swArete1.GetEndVertex
|
| 364 |
|
|
point2 = swSommet.GetPoint
|
| 365 |
|
|
End If
|
| 366 |
|
|
|
| 367 |
|
|
swSommet = swArete2.GetStartVertex
|
| 368 |
|
|
If swSommet Is Nothing Then
|
| 369 |
|
|
point3 = swArete2.Evaluate(0)
|
| 370 |
|
|
point4 = point3
|
| 371 |
|
|
Else
|
| 372 |
|
|
point3 = swSommet.GetPoint
|
| 373 |
|
|
|
| 374 |
|
|
swSommet = swArete2.GetEndVertex
|
| 375 |
|
|
point4 = swSommet.GetPoint
|
| 376 |
|
|
End If
|
| 377 |
|
|
swCourbe1 = swArete1.GetCurve
|
| 378 |
|
|
swCourbe2 = swArete2.GetCurve
|
| 379 |
|
|
|
| 380 |
|
|
|
| 381 |
|
|
vIntersectPts = swCourbe1.IntersectCurve(swCourbe2, point1, point2, point3, point4)
|
| 382 |
|
|
|
| 383 |
|
|
Try ' je déteste cette façon de procéder, mais il ne détecte pas que le vintersectpts est nothing, il le croit system.dbnull. Et je ne peut comparer avec ça.
|
| 384 |
|
|
xyz = vIntersectPts
|
| 385 |
|
|
|
| 386 |
|
|
If Not xyz Is Nothing Then
|
| 387 |
|
|
DetectAreteArete = True
|
| 388 |
|
|
Dim i As Integer
|
| 389 |
|
|
For i = 0 To ((UBound(xyz) + 1) / 4) - 1
|
| 390 |
|
|
Debug.Write("x" & i & " = " & xyz(i * 4) * 1000 & " mm")
|
| 391 |
|
|
Debug.Write("y" & i & " = " & xyz(i * 4) * 1000 & " mm")
|
| 392 |
|
|
Debug.Write("z" & i & " = " & xyz(i * 4) * 1000 & " mm")
|
| 393 |
|
|
Next i
|
| 394 |
|
|
Else
|
| 395 |
|
|
Return False
|
| 396 |
|
|
End If
|
| 397 |
|
|
Catch ex As Exception
|
| 398 |
|
|
DetectAreteArete = False
|
| 399 |
|
|
End Try
|
| 400 |
|
|
|
| 401 |
|
|
End Function
|
| 402 |
|
|
|
| 403 |
|
|
Public Function DetectAreteArete(ByRef swArete1 As SldWorks.Edge, ByRef swCourbe2 As SldWorks.Curve, ByRef xyz() As Double) As Boolean
|
| 404 |
|
|
' function qui détermine si 2 arêtes se touchent, si oui alors la fonction retourne vrai et le tableau XYZ contient le point d'intersection
|
| 405 |
|
|
xyz = Nothing
|
| 406 |
|
|
If swArete1 Is Nothing Then Exit Function
|
| 407 |
|
|
Dim swSommet As SldWorks.Vertex
|
| 408 |
|
|
Dim point1 As Object ' point début courbe 1
|
| 409 |
|
|
Dim point2 As Object ' point fin, courbe 1
|
| 410 |
|
|
Dim point3 As Object ' point début courbe 2
|
| 411 |
|
|
Dim point4 As Object ' point fin, courbe 2
|
| 412 |
|
|
Dim swCourbe1 As SldWorks.Curve
|
| 413 |
|
|
|
| 414 |
|
|
Dim vIntersectPts As Object
|
| 415 |
|
|
|
| 416 |
|
|
swSommet = swArete1.GetStartVertex
|
| 417 |
|
|
If swSommet Is Nothing Then ' cercle fermé
|
| 418 |
|
|
point1 = swArete1.Evaluate(0)
|
| 419 |
|
|
point2 = point1
|
| 420 |
|
|
Else
|
| 421 |
|
|
point1 = swSommet.GetPoint
|
| 422 |
|
|
swSommet = swArete1.GetEndVertex
|
| 423 |
|
|
point2 = swSommet.GetPoint
|
| 424 |
|
|
End If
|
| 425 |
|
|
|
| 426 |
|
|
|
| 427 |
|
|
|
| 428 |
|
|
If Not swCourbe2.IsTrimmedCurve Then
|
| 429 |
|
|
Dim vP1 As Object, vP2 As Object
|
| 430 |
|
|
vP1 = swCourbe2.Evaluate(-9000)
|
| 431 |
|
|
vP2 = swCourbe2.Evaluate(9000)
|
| 432 |
|
|
swCourbe2 = swCourbe2.CreateTrimmedCurve2(vP1(0), vP1(1), vP1(2), vP2(0), vP2(1), vP2(2))
|
| 433 |
|
|
End If
|
| 434 |
|
|
|
| 435 |
|
|
If Not swCourbe2.IsTrimmedCurve Then
|
| 436 |
|
|
MsgBox("Ça plante, le trimmage n'a pas fonctionné...")
|
| 437 |
|
|
End If
|
| 438 |
|
|
|
| 439 |
|
|
Dim dpoint3 As Double, dpoint4 As Double, isClosed As Boolean, isPeriodic As Boolean
|
| 440 |
|
|
swCourbe2.GetEndParams(dpoint3, dpoint4, isClosed, isPeriodic)
|
| 441 |
|
|
|
| 442 |
|
|
point3 = swCourbe2.Evaluate(dpoint3)
|
| 443 |
|
|
point4 = swCourbe2.Evaluate(dpoint4)
|
| 444 |
|
|
|
| 445 |
|
|
swCourbe1 = swArete1.GetCurve
|
| 446 |
|
|
|
| 447 |
|
|
vIntersectPts = swCourbe1.IntersectCurve(swCourbe2, point1, point2, point3, point4)
|
| 448 |
|
|
|
| 449 |
|
|
Try ' je déteste cette façon de procéder, mais il ne détecte pas que le vintersectpts est nothing, il le croit system.dbnull. Et je ne peut comparer avec ça.
|
| 450 |
|
|
xyz = vIntersectPts
|
| 451 |
|
|
|
| 452 |
|
|
If Not xyz Is Nothing Then
|
| 453 |
|
|
DetectAreteArete = True
|
| 454 |
|
|
Dim i As Integer
|
| 455 |
|
|
For i = 0 To ((UBound(xyz) + 1) / 4) - 1
|
| 456 |
|
|
Debug.Write("x" & i & " = " & xyz(i * 4) * 1000 & " mm")
|
| 457 |
|
|
Debug.Write("y" & i & " = " & xyz(i * 4) * 1000 & " mm")
|
| 458 |
|
|
Debug.Write("z" & i & " = " & xyz(i * 4) * 1000 & " mm")
|
| 459 |
|
|
Next i
|
| 460 |
|
|
Else
|
| 461 |
|
|
Return False
|
| 462 |
|
|
End If
|
| 463 |
|
|
Catch ex As Exception
|
| 464 |
|
|
DetectAreteArete = False
|
| 465 |
|
|
End Try
|
| 466 |
|
|
|
| 467 |
|
|
End Function
|
| 468 |
|
|
|
| 469 |
|
|
Private Function isIntersect_milieu(ByRef Arete1 As SldWorks.Edge, ByRef Arete2 As SldWorks.Edge, ByRef x As Double, ByRef y As Double, ByRef z As Double) As Byte
|
| 470 |
|
|
'procédure qui dit si les courbes s'intersectent au milieu ou à leurs point d'extrémité.
|
| 471 |
|
|
' 0 si les deux intersections sont sur des points
|
| 472 |
|
|
' 1 si la première courbe est coupée
|
| 473 |
|
|
' 2 si la deuxième est coupée
|
| 474 |
|
|
' 3 si les deux courbes sont coupées
|
| 475 |
|
|
|
| 476 |
|
|
|
| 477 |
|
|
Dim retv As Object ' mettre les valeurs de T dans la classe
|
| 478 |
|
|
|
| 479 |
|
|
retv = Arete1.GetCurveParams2() ' retv 0,1,2 point de départ, 3,4,5 point final
|
| 480 |
|
|
If (Math.Abs(retv(0) - x) < Epsilon) And (Math.Abs(retv(1) - y) < Epsilon) And (Math.Abs(retv(2) - z) < Epsilon) Or (Math.Abs(retv(3) - x) < Epsilon) And (Math.Abs(retv(4) - y) < Epsilon) And (Math.Abs(retv(5) - z) < Epsilon) Then isIntersect_milieu = 0 Else isIntersect_milieu = 1
|
| 481 |
|
|
|
| 482 |
|
|
retv = Arete2.GetCurveParams2() ' retv 0,1,2 point de départ, 3,4,5 point final
|
| 483 |
|
|
If (Math.Abs(retv(0) - x) < Epsilon) And (Math.Abs(retv(1) - y) < Epsilon) And (Math.Abs(retv(2) - z) < Epsilon) Or (Math.Abs(retv(3) - x) < Epsilon) And (Math.Abs(retv(4) - y) < Epsilon) And (Math.Abs(retv(5) - z) < Epsilon) Then isIntersect_milieu += 0 Else isIntersect_milieu += 2
|
| 484 |
|
|
|
| 485 |
|
|
End Function
|
| 486 |
|
|
|
| 487 |
|
|
|
| 488 |
|
|
''' <summary>
|
| 489 |
|
|
''' Sub qui traite les intersections entre les Poutres et les coques
|
| 490 |
|
|
''' </summary>
|
| 491 |
|
|
''' <remarks></remarks>
|
| 492 |
|
|
Private Sub DetectionPoutresCoques()
|
| 493 |
|
|
'#1 on détecte les intersections, on en a 4 types,
|
| 494 |
|
|
' #1a) intersection au milieu de la coque
|
| 495 |
|
|
' #1b) intersection sur une arête
|
| 496 |
|
|
' #1c) intersection sur un sommet
|
| 497 |
|
|
' #1d) intersection sur une certaine longueur
|
| 498 |
|
|
' faut également faire attention, il peut y avoir plus d'une poutre qui se rejoint à la même intersection.
|
| 499 |
|
|
' hypothèses: 1- les zones d'influence des poutres ne se croisent pas.
|
| 500 |
|
|
' 2- une arête ne fait qu'une seule intersection, à un pount ou sur une ligne, mais pas à plusieurs endroits.
|
| 501 |
|
|
' 3- une arête dont l'intersection est une courbe n'a pas d'autres intersections (pout l'instant)
|
| 502 |
|
|
' lorsqu'une intersection est détectée on créé une instance de la classe InterPoutreCoque
|
| 503 |
|
|
|
| 504 |
|
|
Dim sPoutre As SlyAretePoutre
|
| 505 |
|
|
Dim sCoque As SlyFaceCoque
|
| 506 |
|
|
Dim inter As InterPoutreCoque
|
| 507 |
|
|
Dim xyz() As Double = Nothing
|
| 508 |
|
|
Dim tipe As Byte
|
| 509 |
|
|
Dim i As Integer
|
| 510 |
|
|
Dim premier2 As Boolean
|
| 511 |
|
|
|
| 512 |
|
|
|
| 513 |
|
|
For Each sCoque In lst_FaceCoque
|
| 514 |
|
|
For Each sPoutre In lst_AretePoutre
|
| 515 |
|
|
' on cherche entre la coque et la poutre
|
| 516 |
|
|
|
| 517 |
|
|
If DetectFaceArete(sPoutre.swArete, sCoque.SwFace, xyz) Then
|
| 518 |
|
|
For i = 0 To UBound(xyz) - 1 Step 3
|
| 519 |
|
|
' trouver le tipe d'intersection...
|
| 520 |
|
|
|
| 521 |
|
|
Dim u() As Double
|
| 522 |
|
|
Dim v() As Double
|
| 523 |
|
|
|
| 524 |
|
|
u = sPoutre.GetOrientation(xyz(i + 0), xyz(i + 1), xyz(i + 2))
|
| 525 |
|
|
v = sCoque.GetNormale(xyz(i + 0), xyz(i + 1), xyz(i + 2))
|
| 526 |
|
|
|
| 527 |
|
|
If Math.Abs((Math.Abs(Math.Acos(Outils_Math.cosdir(u, v))) - Pi / 2)) < Epsilon Then
|
| 528 |
|
|
' on est dans le même plan que la coque, on doit déterminer si on sort ou entre dans la coque.
|
| 529 |
|
|
Dim T As Double, T1 As Double, T2 As Double
|
| 530 |
|
|
Dim PointTest(2) As Double
|
| 531 |
|
|
T = sPoutre.GetT(xyz(i + 0), xyz(i + 1), xyz(i + 2))
|
| 532 |
|
|
|
| 533 |
|
|
' on fait T + ou - 15 * epsilon. si une valeur est dans la coque alors on considère que l'on a le type 2
|
| 534 |
|
|
' on prend 15 fois epsilon car à 10, la fonction de solidworks considère que l'on est tellement près que l'on est sur la face
|
| 535 |
|
|
T1 = T + 15 * Epsilon
|
| 536 |
|
|
T2 = T - 15 * Epsilon
|
| 537 |
|
|
|
| 538 |
|
|
Dim effacer As Double
|
| 539 |
|
|
|
| 540 |
|
|
If sPoutre.Evaluer(T1, PointTest) Then
|
| 541 |
|
|
' la valeur de T appartient à la poutre, maintenant on vérifie s'il appartient aussi à la coque
|
| 542 |
|
|
If Distance(sCoque.lst_Faces.Item(1), PointTest(0), PointTest(1), PointTest(2)) < Epsilon Then
|
| 543 |
|
|
' on est dans la coque.
|
| 544 |
|
|
If Not premier2 Then tipe = 2 : premier2 = True Else tipe = 22
|
| 545 |
|
|
End If
|
| 546 |
|
|
End If
|
| 547 |
|
|
|
| 548 |
|
|
If sPoutre.Evaluer(T2, PointTest) Then
|
| 549 |
|
|
effacer = Distance(sCoque.lst_Faces.Item(1), PointTest(0), PointTest(1), PointTest(2))
|
| 550 |
|
|
If Distance(sCoque.lst_Faces.Item(1), PointTest(0), PointTest(1), PointTest(2)) < Epsilon Then
|
| 551 |
|
|
If Not premier2 Then tipe = 2 : premier2 = True Else tipe = 22
|
| 552 |
|
|
End If
|
| 553 |
|
|
End If
|
| 554 |
|
|
|
| 555 |
|
|
|
| 556 |
|
|
' si tipe n'est pas à 2 alors on est par défaut à 3
|
| 557 |
|
|
If tipe = 0 Then tipe = 3
|
| 558 |
|
|
|
| 559 |
|
|
Else
|
| 560 |
|
|
tipe = 1 ' on va devoir couper en X
|
| 561 |
|
|
End If
|
| 562 |
|
|
|
| 563 |
|
|
inter = sCoque.AjouterInterPoutre(sPoutre, xyz, tipe)
|
| 564 |
|
|
sPoutre.lst_InterCoque.Add(inter)
|
| 565 |
|
|
tipe = 0 ' reset
|
| 566 |
|
|
|
| 567 |
|
|
Next i ' autre point d'intersection
|
| 568 |
|
|
|
| 569 |
|
|
End If
|
| 570 |
|
|
premier2 = False ' reset
|
| 571 |
|
|
Next sPoutre
|
| 572 |
|
|
Next sCoque
|
| 573 |
|
|
End Sub
|
| 574 |
|
|
|
| 575 |
|
|
|
| 576 |
|
|
|
| 577 |
|
|
''' <summary>
|
| 578 |
|
|
''' Sub qui procède au découpage des coques en fonction des poutres
|
| 579 |
|
|
''' </summary>
|
| 580 |
|
|
''' <remarks></remarks>
|
| 581 |
|
|
Private Sub DecouperPoutreCoque()
|
| 582 |
|
|
' #2 on procède au découpage de la face
|
| 583 |
|
|
Dim sCoque As SlyFaceCoque
|
| 584 |
|
|
For Each sCoque In lst_FaceCoque
|
| 585 |
|
|
If sCoque.lst_InterPoutre.Count > 0 Then
|
| 586 |
|
|
'sVol.chercherAttributs()
|
| 587 |
|
|
sCoque.decouper()
|
| 588 |
|
|
|
| 589 |
|
|
' on met-a-jour l'attribut des conditions aux limites
|
| 590 |
|
|
Dim attr As SldWorks.Attribute
|
| 591 |
|
|
Dim swent As SldWorks.Entity
|
| 592 |
|
|
Dim nom3 As String = Nothing
|
| 593 |
|
|
Dim p As SldWorks.Parameter
|
| 594 |
|
|
If Not sCoque.AttributCL Is Nothing Then
|
| 595 |
|
|
nom3 = "CL_" & sCoque.nom
|
| 596 |
|
|
swent = sCoque.lst_Faces.Item(1)
|
| 597 |
|
|
attr = swent.FindAttribute(Intersections.DefAttrConditionLimite, 0) ' si l'attribut existe déjà on pointe dessus.
|
| 598 |
|
|
|
| 599 |
|
|
If attr Is Nothing Then attr = Intersections.DefAttrConditionLimite.CreateInstance5(swModel, sCoque.lst_Faces.Item(1), nom3, 0, 0)
|
| 600 |
|
|
p = attr.GetParameter("CL")
|
| 601 |
|
|
p.SetStringValue(sCoque.condition)
|
| 602 |
|
|
|
| 603 |
|
|
End If
|
| 604 |
|
|
GererDossiers("Conditions Aux Limites", nom3)
|
| 605 |
|
|
End If
|
| 606 |
|
|
|
| 607 |
|
|
Next
|
| 608 |
|
|
End Sub
|
| 609 |
|
|
|
| 610 |
|
|
|
| 611 |
|
|
''' <summary>
|
| 612 |
|
|
''' Sub qui détecte les intersections entre les faces du volume et les poutres
|
| 613 |
|
|
''' </summary>
|
| 614 |
|
|
''' <remarks></remarks>
|
| 615 |
|
|
Private Sub DetectionPoutresVolumes()
|
| 616 |
|
|
Dim sPoutre As SlyAretePoutre
|
| 617 |
|
|
|
| 618 |
|
|
For Each sPoutre In lst_AretePoutre
|
| 619 |
|
|
If Not sPoutre.IsFaceDeSection Then
|
| 620 |
|
|
Call Intersections.GestionPoutreNormaleAvecVolume(sPoutre)
|
| 621 |
|
|
Else
|
| 622 |
|
|
' la poutre est flaggée pour prendre la face de section
|
| 623 |
|
|
Call Intersections.GestionFace_De_section(sPoutre)
|
| 624 |
|
|
End If
|
| 625 |
|
|
Next sPoutre
|
| 626 |
|
|
End Sub
|
| 627 |
|
|
|
| 628 |
|
|
''' <summary>
|
| 629 |
|
|
''' Sub qui prend les intersections entre les faces et les volumes et qui coupe les volumes
|
| 630 |
|
|
''' </summary>
|
| 631 |
|
|
''' <remarks></remarks>
|
| 632 |
|
|
Private Sub DecouperPoutreVolume()
|
| 633 |
|
|
' #2 on procède au découpage de la face
|
| 634 |
|
|
Dim sVol As SlyFaceVolume
|
| 635 |
|
|
|
| 636 |
|
|
For Each sVol In lst_FaceVolume
|
| 637 |
|
|
If sVol.lst_InterPoutre.Count > 0 Then
|
| 638 |
|
|
sVol.decouper()
|
| 639 |
|
|
|
| 640 |
|
|
' on met-a-jour l'attribut des conditions aux limites
|
| 641 |
|
|
Dim attr As SldWorks.Attribute
|
| 642 |
|
|
Dim swent As SldWorks.Entity
|
| 643 |
|
|
Dim nom3 As String = Nothing
|
| 644 |
|
|
Dim p As SldWorks.Parameter
|
| 645 |
|
|
If Not sVol.AttributCL Is Nothing Then
|
| 646 |
|
|
nom3 = "CL_" & sVol.nom
|
| 647 |
|
|
swent = sVol.SwFace
|
| 648 |
|
|
attr = swent.FindAttribute(Intersections.DefAttrConditionLimite, 0) ' si l'attribut existe déjà on pointe dessus.
|
| 649 |
|
|
|
| 650 |
|
|
If attr Is Nothing Then attr = Intersections.DefAttrConditionLimite.CreateInstance5(swModel, sVol.SwFace, nom3, 0, 0)
|
| 651 |
|
|
p = attr.GetParameter("CL")
|
| 652 |
|
|
p.SetStringValue(sVol.condition)
|
| 653 |
|
|
|
| 654 |
|
|
End If
|
| 655 |
|
|
GererDossiers("Conditions Aux Limites", nom3)
|
| 656 |
|
|
End If
|
| 657 |
|
|
|
| 658 |
|
|
Next
|
| 659 |
|
|
End Sub
|
| 660 |
|
|
|
| 661 |
|
|
|
| 662 |
|
|
|
| 663 |
|
|
|
| 664 |
|
|
|
| 665 |
|
|
''' <summary>
|
| 666 |
|
|
''' Sub qui gère la poutre qui a été flaggée comme ayant une face de section. Met à jour les attributs avec les bonnes inerties et autre
|
| 667 |
|
|
''' </summary>
|
| 668 |
|
|
''' <param name="sPoutre">La poutre avec laquelle il faut travailler</param>
|
| 669 |
|
|
''' <remarks></remarks>
|
| 670 |
|
|
Private Sub GestionFace_De_section(ByRef sPoutre As SlyAretePoutre)
|
| 671 |
|
|
|
| 672 |
|
|
Dim sVol As SlyFaceVolume
|
| 673 |
|
|
Dim swExt As SldWorks.ModelDocExtension
|
| 674 |
|
|
Dim xyz() As Double = Nothing, xyz2() As Double = Nothing
|
| 675 |
|
|
Dim section As Object
|
| 676 |
|
|
Dim Face1 As SlyFaceVolume = Nothing, prop1() As Double = Nothing
|
| 677 |
|
|
Dim Face2 As SlyFaceVolume = Nothing, prop2() As Double = Nothing
|
| 678 |
|
|
Dim proprietes() As Double
|
| 679 |
|
|
Dim i As Integer
|
| 680 |
|
|
swExt = swModel.Extension
|
| 681 |
|
|
|
| 682 |
|
|
' 1 - Spotter la ou les faces en question
|
| 683 |
|
|
xyz = sPoutre.GetStartPoint
|
| 684 |
|
|
xyz2 = sPoutre.GetEndPoint
|
| 685 |
|
|
For Each sVol In Commun.lst_FaceVolume
|
| 686 |
|
|
If Intersections.DetectSurfaceArete(sPoutre.swArete, sVol.SwFace, Nothing) Then
|
| 687 |
|
|
swModel.ClearSelection2(True)
|
| 688 |
|
|
sVol.Selectionner()
|
| 689 |
|
|
section = swExt.GetSectionProperties2(sVol.SwFace) : proprietes = section
|
| 690 |
|
|
swModel.ClearSelection2(True)
|
| 691 |
|
|
' la fontion getsectionproperties renvoie des valeurs dont la précision est très douteuse...
|
| 692 |
|
|
' on met alors une beaucoup plus grosse tolérance...
|
| 693 |
|
|
If Math.Abs(xyz(0) - proprietes(2)) < 0.0001 And Math.Abs(xyz(1) - proprietes(3)) < 0.0001 And Math.Abs(xyz(2) - proprietes(4)) < 0.0001 Then Face1 = sVol : prop1 = proprietes
|
| 694 |
|
|
If Math.Abs(xyz2(0) - proprietes(2)) < 0.0001 And Math.Abs(xyz2(1) - proprietes(3)) < 0.0001 And Math.Abs(xyz2(2) - proprietes(4)) < 0.0001 Then Face2 = sVol : prop2 = proprietes
|
| 695 |
|
|
End If
|
| 696 |
|
|
Next
|
| 697 |
|
|
|
| 698 |
|
|
' si les 2 faces sont nothing, c'est que l'on a un sérieux problème...
|
| 699 |
|
|
If Face1 Is Nothing AndAlso Face2 Is Nothing Then
|
| 700 |
|
|
MsgBox("La poutre " & sPoutre.nom & " doit avoir au moins une face pour évaluer sa section. Cette face n'a pas été trouvée." & vbCr & vbCr & " Vérifiez que: " & vbCr & " - Un sommet de la poutre repose sur le centre de gravité d'une face" & vbCr & " - Que l'arète de la poutre est perpendiculaire à la face" & vbCr & " - Que la face est plane " & vbCr & " - Je crois avoir tout couvert..." & vbCr & vbCr & " La poutre a problème a été colorée en rouge.", MsgBoxStyle.Critical, "Impossible de trouver la face représentant la section")
|
| 701 |
|
|
Dim e As New SuperArete(sPoutre.swArete, True)
|
| 702 |
|
|
e.Colorer(3, 1, 0, 0)
|
| 703 |
|
|
sPoutre.Selectionner()
|
| 704 |
|
|
Exit Sub
|
| 705 |
|
|
End If
|
| 706 |
|
|
|
| 707 |
|
|
|
| 708 |
|
|
|
| 709 |
|
|
' 2 - s'assurer que:
|
| 710 |
|
|
' 2.1 les 2 faces sont identiques (si 2 faces)
|
| 711 |
|
|
If Face1 IsNot Nothing And Face2 IsNot Nothing Then
|
| 712 |
|
|
If Not Math.Abs(prop1(1) - prop2(1)) < 0.0000001 Then
|
| 713 |
|
|
Dim chaine As String
|
| 714 |
|
|
chaine = "Les 2 faces ne sont pas identiques... "
|
| 715 |
|
|
For i = 0 To 14
|
| 716 |
|
|
chaine = chaine & vbCr & i & " - " & Format(prop1(i), "0.000E+00") & " " & Format(prop2(i), "0.000E+00")
|
| 717 |
|
|
Next i
|
| 718 |
|
|
MsgBox(chaine)
|
| 719 |
|
|
End If
|
| 720 |
|
|
End If
|
| 721 |
|
|
' 2.2 le centroide est au point d'intersection
|
| 722 |
|
|
' déjà fait
|
| 723 |
|
|
' 2.3 la face est plane
|
| 724 |
|
|
If Face1 IsNot Nothing Then
|
| 725 |
|
|
If Not (Face1.estPlan Xor Face1.estFauxPlan(prop1(2), prop1(3), prop1(4))) Then
|
| 726 |
|
|
MsgBox("La face 1 n'est pas plane!")
|
| 727 |
|
|
Err.Raise(513, , "Ne peut pas prendre une face non plane comme source de la section de la poutre")
|
| 728 |
|
|
End If
|
| 729 |
|
|
End If
|
| 730 |
|
|
If Face2 IsNot Nothing Then
|
| 731 |
|
|
If Not (Face2.estPlan Xor Face2.estFauxPlan(prop1(2), prop1(3), prop1(4))) Then
|
| 732 |
|
|
MsgBox("La face 2 n'est pas plane!")
|
| 733 |
|
|
Err.Raise(513, , "Ne peut pas prendre une face non plane comme source de la section de la poutre")
|
| 734 |
|
|
End If
|
| 735 |
|
|
End If
|
| 736 |
|
|
|
| 737 |
|
|
|
| 738 |
|
|
' 2.4 les face sont perpendiculaire aux point d'intersection
|
| 739 |
|
|
Dim u() As Double
|
| 740 |
|
|
Dim v() As Double
|
| 741 |
|
|
Dim angle As Double
|
| 742 |
|
|
If Face1 IsNot Nothing Then
|
| 743 |
|
|
u = Face1.GetNormaleSurface(prop1(2), prop1(3), prop1(4))
|
| 744 |
|
|
v = sPoutre.GetOrientation(prop1(2), prop1(3), prop1(4))
|
| 745 |
|
|
angle = Outils_Math.Angle2Vecteurs(u, v)
|
| 746 |
|
|
If Not (Math.Abs(angle - Pi) < (100 * Epsilon)) And Not (angle < 0.005) Then
|
| 747 |
|
|
MsgBox("La poutre n'est pas perpendiculaire à la face1")
|
| 748 |
|
|
Err.Raise(514, "GestionFace_de_section - Dans intersection.vb", "Ne peut pas traiter une poutre dont la face de base n'est pas perpendiculaire")
|
| 749 |
|
|
End If
|
| 750 |
|
|
End If
|
| 751 |
|
|
|
| 752 |
|
|
If Face2 IsNot Nothing Then
|
| 753 |
|
|
u = Face2.GetNormaleSurface(prop2(2), prop2(3), prop2(4))
|
| 754 |
|
|
v = sPoutre.GetOrientation(prop2(2), prop2(3), prop2(4))
|
| 755 |
|
|
angle = Outils_Math.Angle2Vecteurs(u, v)
|
| 756 |
|
|
If Not (Math.Abs(angle - Pi) < (100 * Epsilon)) And Not (angle < Epsilon) Then
|
| 757 |
|
|
MsgBox("La poutre n'est pas perpendiculaire à la face2")
|
| 758 |
|
|
Err.Raise(514, "GestionFace_de_section - Dans intersection.vb", "Ne peut pas traiter une poutre dont la face de base n'est pas perpendiculaire")
|
| 759 |
|
|
End If
|
| 760 |
|
|
End If
|
| 761 |
|
|
|
| 762 |
|
|
' 3 - trouver l'inertie et l'aire, placer le point 3 de façon cohérente, updater l'attribut.
|
| 763 |
|
|
Dim Nom3 As String
|
| 764 |
|
|
|
| 765 |
|
|
Commun.MettreUnPoint(prop1(2) + prop1(18) / 1000, prop1(3) + prop1(19) / 1000, prop1(4) + prop1(20) / 1000, True)
|
| 766 |
|
|
Nom3 = RealConstant.RCCode.Creation3iemePoint(1)
|
| 767 |
|
|
sPoutre.SetAttributsDePoutre(False, Nom3, , , prop1(13), prop1(14), prop1(1), , , , , , , 1)
|
| 768 |
|
|
|
| 769 |
|
|
' 4 créer une nouvelle instance de la classe interFacePoutre de tipe 5
|
| 770 |
|
|
Dim inter As New InterPoutreVolume
|
| 771 |
|
|
Dim inter2 As New InterPoutreVolume
|
| 772 |
|
|
If Face1 IsNot Nothing Then
|
| 773 |
|
|
xyz(0) = prop1(2) : xyz(1) = prop1(3) : xyz(2) = prop1(4)
|
| 774 |
|
|
inter = Face1.AjouterInterPoutre(sPoutre, xyz, 5)
|
| 775 |
|
|
sPoutre.lst_InterCoque.Add(inter)
|
| 776 |
|
|
End If
|
| 777 |
|
|
|
| 778 |
|
|
If Face2 IsNot Nothing Then
|
| 779 |
|
|
xyz(0) = prop2(2) : xyz(1) = prop2(3) : xyz(2) = prop2(4)
|
| 780 |
|
|
inter2 = Face2.AjouterInterPoutre(sPoutre, xyz, 5)
|
| 781 |
|
|
sPoutre.lst_InterCoque.Add(inter2)
|
| 782 |
|
|
End If
|
| 783 |
|
|
|
| 784 |
|
|
End Sub
|
| 785 |
|
|
|
| 786 |
|
|
|
| 787 |
|
|
''' <summary>
|
| 788 |
|
|
''' Sub qui trouve les intersections entre les poutres et les faces de volumes et qui créé une instance de la classe d'intersection
|
| 789 |
|
|
''' </summary>
|
| 790 |
|
|
''' <param name="sPoutre">La poutre avec laquelle il faut trouver les intersections</param>
|
| 791 |
|
|
''' <remarks></remarks>
|
| 792 |
|
|
Private Sub GestionPoutreNormaleAvecVolume(ByRef sPoutre As SlyAretePoutre)
|
| 793 |
|
|
Dim inter As InterPoutreVolume
|
| 794 |
|
|
Dim xyz() As Double = Nothing
|
| 795 |
|
|
Dim tipe As Byte
|
| 796 |
|
|
Dim i As Integer
|
| 797 |
|
|
Dim premier2 As Boolean
|
| 798 |
|
|
Dim sVol As SlyFaceVolume
|
| 799 |
|
|
|
| 800 |
|
|
For Each sVol In lst_FaceVolume
|
| 801 |
|
|
|
| 802 |
|
|
|
| 803 |
|
|
' on cherche entre la coque et la poutre
|
| 804 |
|
|
|
| 805 |
|
|
|
| 806 |
|
|
|
| 807 |
|
|
If DetectFaceArete(sPoutre.swArete, sVol, xyz) Then
|
| 808 |
|
|
|
| 809 |
|
|
For i = 0 To UBound(xyz) - 1 Step 3
|
| 810 |
|
|
' trouver le tipe d'intersection...
|
| 811 |
|
|
|
| 812 |
|
|
Dim u() As Double
|
| 813 |
|
|
Dim v() As Double
|
| 814 |
|
|
|
| 815 |
|
|
u = sPoutre.GetOrientation(xyz(i + 0), xyz(i + 1), xyz(i + 2))
|
| 816 |
|
|
v = sVol.GetNormale(xyz(i + 0), xyz(i + 1), xyz(i + 2))
|
| 817 |
|
|
|
| 818 |
|
|
' ***** ici, différencier entre coque et volume ****
|
| 819 |
|
|
If Math.Abs((Math.Abs(Math.Acos(Outils_Math.cosdir(u, v))) - Pi / 2)) < Epsilon Then
|
| 820 |
|
|
' on est dans le même plan que la coque, on doit déterminer si on sort ou entre dans la coque.
|
| 821 |
|
|
Dim T As Double, T1 As Double, T2 As Double
|
| 822 |
|
|
Dim PointTest(2) As Double
|
| 823 |
|
|
T = sPoutre.GetT(xyz(i + 0), xyz(i + 1), xyz(i + 2))
|
| 824 |
|
|
|
| 825 |
|
|
' on fait T + ou - 15 * epsilon. si une valeur est dans la coque alors on considère que l'on a le type 2
|
| 826 |
|
|
' on prend 15 fois epxilon car à 10, la fonction de solidworks considère que l'on est tellement près que l'on est sur la face
|
| 827 |
|
|
T1 = T + 15 * Epsilon
|
| 828 |
|
|
T2 = T - 15 * Epsilon
|
| 829 |
|
|
|
| 830 |
|
|
Dim effacer As Double
|
| 831 |
|
|
|
| 832 |
|
|
If sPoutre.Evaluer(T1, PointTest) Then
|
| 833 |
|
|
' la valeur de T appartient à la poutre, maintenant on vérifie s'il appartient aussi à la coque
|
| 834 |
|
|
If Distance(sVol.SwFace, PointTest(0), PointTest(1), PointTest(2)) < Epsilon Then
|
| 835 |
|
|
' on est dans la coque.
|
| 836 |
|
|
If Not premier2 Then tipe = 2 : premier2 = True Else tipe = 22
|
| 837 |
|
|
End If
|
| 838 |
|
|
End If
|
| 839 |
|
|
|
| 840 |
|
|
If sPoutre.Evaluer(T2, PointTest) Then
|
| 841 |
|
|
effacer = Distance(sVol.SwFace, PointTest(0), PointTest(1), PointTest(2))
|
| 842 |
|
|
If Distance(sVol.SwFace, PointTest(0), PointTest(1), PointTest(2)) < Epsilon Then
|
| 843 |
|
|
If Not premier2 Then tipe = 2 : premier2 = True Else tipe = 22
|
| 844 |
|
|
End If
|
| 845 |
|
|
End If
|
| 846 |
|
|
|
| 847 |
|
|
' si tipe n'est pas à 2 alors on est par défaut à 3
|
| 848 |
|
|
If tipe = 0 Then tipe = 3
|
| 849 |
|
|
|
| 850 |
|
|
Else
|
| 851 |
|
|
tipe = 1 ' on va devoir couper en X
|
| 852 |
|
|
End If
|
| 853 |
|
|
|
| 854 |
|
|
inter = sVol.AjouterInterPoutre(sPoutre, xyz, tipe)
|
| 855 |
|
|
sPoutre.lst_InterCoque.Add(inter)
|
| 856 |
|
|
tipe = 0 ' reset
|
| 857 |
|
|
|
| 858 |
|
|
Next i ' autre point d'intersection
|
| 859 |
|
|
|
| 860 |
|
|
End If
|
| 861 |
|
|
premier2 = False ' reset
|
| 862 |
|
|
|
| 863 |
|
|
Next sVol
|
| 864 |
|
|
End Sub
|
| 865 |
|
|
|
| 866 |
|
|
|
| 867 |
|
|
|
| 868 |
|
|
|
| 869 |
|
|
'Private Function DetectFaceArete(ByRef swCurve As SldWorks.Curve, ByRef swFace As SldWorks.Face2, ByRef xyz() As Double) As Boolean
|
| 870 |
|
|
' ' function qui détecte si une arête coupe une face, si c'est le cas la function retourne true et remplie le tableau xyz avec le point d'intersection
|
| 871 |
|
|
' Dim vCurveParam As Object
|
| 872 |
|
|
' Dim swSurf As SldWorks.Surface
|
| 873 |
|
|
' Dim vCurveBounds As Object, vPointArray As Object, vTArray As Object, vUVArray As Object
|
| 874 |
|
|
' Dim nCurveBounds(5) As Double
|
| 875 |
|
|
' Dim bRet As Boolean
|
| 876 |
|
|
' Dim i As Integer
|
| 877 |
|
|
|
| 878 |
|
|
' swSurf = swFace.GetSurface
|
| 879 |
|
|
|
| 880 |
|
|
' ' 2- on va chercher les paramètres de la spline avec Curve::ConvertLineToBcurve
|
| 881 |
|
|
' If swCurve.IsLine Then
|
| 882 |
|
|
' Dim startp(2) As Double
|
| 883 |
|
|
' Dim endp(2) As Double
|
| 884 |
|
|
' Dim vStart As Object
|
| 885 |
|
|
' Dim vEnd As Object
|
| 886 |
|
|
|
| 887 |
|
|
' vCurveParam = swCurve.LineParams()
|
| 888 |
|
|
' startp(0) = vCurveParam(0)
|
| 889 |
|
|
' startp(1) = vCurveParam(1)
|
| 890 |
|
|
' startp(2) = vCurveParam(2)
|
| 891 |
|
|
' vStart = startp
|
| 892 |
|
|
|
| 893 |
|
|
' endp(0) = vCurveParam(3)
|
| 894 |
|
|
' endp(1) = vCurveParam(4)
|
| 895 |
|
|
' endp(2) = vCurveParam(5)
|
| 896 |
|
|
' vEnd = endp
|
| 897 |
|
|
|
| 898 |
|
|
' Dim retval As Object
|
| 899 |
|
|
' Dim valeur As Double
|
| 900 |
|
|
' Dim dimension As Integer
|
| 901 |
|
|
' Dim ordre As Integer
|
| 902 |
|
|
' Dim nbpoints As Integer
|
| 903 |
|
|
' Dim periodique As Integer
|
| 904 |
|
|
|
| 905 |
|
|
' retval = swCurve.ConvertLineToBcurve(vStart, vEnd)
|
| 906 |
|
|
|
| 907 |
|
|
' ' on suppose que la droite est toujours transformée en spline non-rationelle de dimension 3 et d'ordre 2
|
| 908 |
|
|
' Dim knots(3) As Double
|
| 909 |
|
|
' Dim ctrlPoints(5) As Double
|
| 910 |
|
|
|
| 911 |
|
|
' knots(0) = retval(2)
|
| 912 |
|
|
' knots(1) = retval(3)
|
| 913 |
|
|
' knots(2) = retval(4)
|
| 914 |
|
|
' knots(3) = retval(5)
|
| 915 |
|
|
|
| 916 |
|
|
' ctrlPoints(0) = retval(6)
|
| 917 |
|
|
' ctrlPoints(1) = retval(7)
|
| 918 |
|
|
' ctrlPoints(2) = retval(8)
|
| 919 |
|
|
' ctrlPoints(3) = retval(9)
|
| 920 |
|
|
' ctrlPoints(4) = retval(10)
|
| 921 |
|
|
' ctrlPoints(5) = retval(11)
|
| 922 |
|
|
|
| 923 |
|
|
' '3 - on créé une spline dans le modeleur
|
| 924 |
|
|
|
| 925 |
|
|
|
| 926 |
|
|
' Dim modeler As SldWorks.Modeler
|
| 927 |
|
|
' modeler = swApp.GetModeler
|
| 928 |
|
|
' Dim props As Object
|
| 929 |
|
|
' Dim dProps(1) As Double
|
| 930 |
|
|
' Dim vKnots As Object, vCtrlPoints As Object
|
| 931 |
|
|
|
| 932 |
|
|
' dProps(0) = retval(0)
|
| 933 |
|
|
' dProps(1) = retval(1)
|
| 934 |
|
|
' props = dProps
|
| 935 |
|
|
' vKnots = knots
|
| 936 |
|
|
' vCtrlPoints = ctrlPoints
|
| 937 |
|
|
|
| 938 |
|
|
' swCurve = modeler.CreateBsplineCurve(props, vKnots, vCtrlPoints)
|
| 939 |
|
|
' ' 4 - on a une spline, on peut utiliser la fonction IntersectCurve
|
| 940 |
|
|
' End If
|
| 941 |
|
|
|
| 942 |
|
|
|
| 943 |
|
|
' For i = 0 To 5
|
| 944 |
|
|
' nCurveBounds(i) = vCurveParam(i)
|
| 945 |
|
|
' Next i
|
| 946 |
|
|
|
| 947 |
|
|
' vCurveBounds = nCurveBounds
|
| 948 |
|
|
' bRet = swSurf.IntersectCurve(swCurve, vCurveBounds, vPointArray, vTArray, vUVArray)
|
| 949 |
|
|
|
| 950 |
|
|
' Dim Pts() As Double
|
| 951 |
|
|
' Dim PointsTemp() As Double
|
| 952 |
|
|
' Dim j As Integer
|
| 953 |
|
|
|
| 954 |
|
|
' Pts = vPointArray
|
| 955 |
|
|
|
| 956 |
|
|
' If UBound(Pts) < 1 Then Return False
|
| 957 |
|
|
' ' ATTENTION, le point n'est pas nécessairement dans la face
|
| 958 |
|
|
' For i = 0 To UBound(Pts) - 1 Step 3
|
| 959 |
|
|
' If Commun.Distance(swFace, Pts(i + 0), Pts(i + 1), Pts(i + 2)) < Epsilon Then
|
| 960 |
|
|
' ReDim Preserve PointsTemp(j + 2)
|
| 961 |
|
|
' PointsTemp(j) = Pts(i + 0)
|
| 962 |
|
|
' PointsTemp(j + 1) = Pts(i + 1)
|
| 963 |
|
|
' PointsTemp(j + 2) = Pts(i + 2)
|
| 964 |
|
|
' j += 3
|
| 965 |
|
|
' End If
|
| 966 |
|
|
' Next
|
| 967 |
|
|
|
| 968 |
|
|
' xyz = PointsTemp
|
| 969 |
|
|
' If xyz Is Nothing Then Return False
|
| 970 |
|
|
' If UBound(xyz) > 0 Then Return True
|
| 971 |
|
|
|
| 972 |
|
|
|
| 973 |
|
|
'End Function
|
| 974 |
|
|
|
| 975 |
|
|
Private Function DetectFaceArete(ByRef swArete As SldWorks.Edge, ByRef swFace As SldWorks.Face2, ByRef xyz() As Double) As Boolean
|
| 976 |
|
|
' function qui détecte si une arête coupe une face, si c'est le cas la function retourne true et remplie le tableau xyz avec le point d'intersection
|
| 977 |
|
|
|
| 978 |
|
|
Dim P1 As Object = Nothing, p2 As Object = Nothing
|
| 979 |
bournival |
48 |
If swModel.ClosestDistance(swArete, swFace, P1, p2) > Epsilon Then Return False
|
| 980 |
bournival |
40 |
|
| 981 |
|
|
Dim swCurve As SldWorks.Curve
|
| 982 |
|
|
Dim swSurf As SldWorks.Surface
|
| 983 |
|
|
Dim vCurveParam As Object
|
| 984 |
|
|
|
| 985 |
|
|
Dim vCurveBounds As Object, vPointArray As Object = Nothing, vTArray As Object = Nothing, vUVArray As Object = Nothing
|
| 986 |
|
|
Dim nCurveBounds(5) As Double
|
| 987 |
|
|
Dim bRet As Boolean
|
| 988 |
|
|
Dim i As Integer
|
| 989 |
|
|
|
| 990 |
|
|
'1 - on va chercher la courbe et la surface
|
| 991 |
|
|
swCurve = swArete.GetCurve
|
| 992 |
|
|
swSurf = swFace.GetSurface
|
| 993 |
|
|
|
| 994 |
|
|
|
| 995 |
|
|
' 2- on va chercher les paramètres de la spline avec Curve::ConvertLineToBcurve
|
| 996 |
|
|
vCurveParam = swArete.GetCurveParams2
|
| 997 |
|
|
If swCurve.IsLine Then
|
| 998 |
|
|
Dim startp(2) As Double
|
| 999 |
|
|
Dim endp(2) As Double
|
| 1000 |
|
|
Dim vStart As Object
|
| 1001 |
|
|
Dim vEnd As Object
|
| 1002 |
|
|
|
| 1003 |
|
|
|
| 1004 |
|
|
startp(0) = vCurveParam(0)
|
| 1005 |
|
|
startp(1) = vCurveParam(1)
|
| 1006 |
|
|
startp(2) = vCurveParam(2)
|
| 1007 |
|
|
vStart = startp
|
| 1008 |
|
|
|
| 1009 |
|
|
endp(0) = vCurveParam(3)
|
| 1010 |
|
|
endp(1) = vCurveParam(4)
|
| 1011 |
|
|
endp(2) = vCurveParam(5)
|
| 1012 |
|
|
vEnd = endp
|
| 1013 |
|
|
|
| 1014 |
|
|
Dim retval As Object
|
| 1015 |
|
|
|
| 1016 |
|
|
retval = swCurve.ConvertLineToBcurve(vStart, vEnd)
|
| 1017 |
|
|
|
| 1018 |
|
|
' on suppose que la droite est toujours transformée en spline non-rationelle de dimension 3 et d'ordre 2
|
| 1019 |
|
|
Dim knots(3) As Double
|
| 1020 |
|
|
Dim ctrlPoints(5) As Double
|
| 1021 |
|
|
|
| 1022 |
|
|
knots(0) = retval(2)
|
| 1023 |
|
|
knots(1) = retval(3)
|
| 1024 |
|
|
knots(2) = retval(4)
|
| 1025 |
|
|
knots(3) = retval(5)
|
| 1026 |
|
|
|
| 1027 |
|
|
ctrlPoints(0) = retval(6)
|
| 1028 |
|
|
ctrlPoints(1) = retval(7)
|
| 1029 |
|
|
ctrlPoints(2) = retval(8)
|
| 1030 |
|
|
ctrlPoints(3) = retval(9)
|
| 1031 |
|
|
ctrlPoints(4) = retval(10)
|
| 1032 |
|
|
ctrlPoints(5) = retval(11)
|
| 1033 |
|
|
|
| 1034 |
|
|
'3 - on créé une spline dans le modeleur
|
| 1035 |
|
|
|
| 1036 |
|
|
|
| 1037 |
|
|
Dim modeler As SldWorks.Modeler
|
| 1038 |
|
|
modeler = swApp.GetModeler
|
| 1039 |
|
|
Dim props As Object
|
| 1040 |
|
|
Dim dProps(1) As Double
|
| 1041 |
|
|
Dim vKnots As Object, vCtrlPoints As Object
|
| 1042 |
|
|
|
| 1043 |
|
|
dProps(0) = retval(0)
|
| 1044 |
|
|
dProps(1) = retval(1)
|
| 1045 |
|
|
props = dProps
|
| 1046 |
|
|
vKnots = knots
|
| 1047 |
|
|
vCtrlPoints = ctrlPoints
|
| 1048 |
|
|
|
| 1049 |
|
|
swCurve = modeler.CreateBsplineCurve(props, vKnots, vCtrlPoints)
|
| 1050 |
|
|
' 4 - on a une spline, on peut utiliser la fonction IntersectCurve
|
| 1051 |
|
|
End If
|
| 1052 |
|
|
|
| 1053 |
|
|
|
| 1054 |
|
|
For i = 0 To 5
|
| 1055 |
|
|
nCurveBounds(i) = vCurveParam(i)
|
| 1056 |
|
|
Next i
|
| 1057 |
|
|
|
| 1058 |
|
|
vCurveBounds = nCurveBounds
|
| 1059 |
|
|
bRet = swSurf.IntersectCurve(swCurve, vCurveBounds, vPointArray, vTArray, vUVArray)
|
| 1060 |
|
|
|
| 1061 |
|
|
Dim Pts() As Double
|
| 1062 |
|
|
Dim PointsTemp() As Double = Nothing
|
| 1063 |
|
|
Dim j As Integer
|
| 1064 |
|
|
|
| 1065 |
|
|
Pts = vPointArray
|
| 1066 |
|
|
|
| 1067 |
|
|
If UBound(Pts) < 1 Then Return False
|
| 1068 |
|
|
' ATTENTION, le point n'est pas nécessairement dans la face
|
| 1069 |
|
|
For i = 0 To UBound(Pts) - 1 Step 3
|
| 1070 |
|
|
If Commun.Distance(swFace, Pts(i + 0), Pts(i + 1), Pts(i + 2)) < Epsilon Then
|
| 1071 |
|
|
ReDim Preserve PointsTemp(j + 2)
|
| 1072 |
|
|
PointsTemp(j) = Pts(i + 0)
|
| 1073 |
|
|
PointsTemp(j + 1) = Pts(i + 1)
|
| 1074 |
|
|
PointsTemp(j + 2) = Pts(i + 2)
|
| 1075 |
|
|
j += 3
|
| 1076 |
|
|
End If
|
| 1077 |
|
|
Next
|
| 1078 |
|
|
|
| 1079 |
|
|
xyz = PointsTemp
|
| 1080 |
|
|
If xyz Is Nothing Then Return False
|
| 1081 |
|
|
If UBound(xyz) > 0 Then Return True
|
| 1082 |
|
|
|
| 1083 |
|
|
End Function
|
| 1084 |
|
|
|
| 1085 |
|
|
|
| 1086 |
|
|
|
| 1087 |
|
|
Private Function DetectFaceArete(ByRef swArete As SldWorks.Edge, ByRef Slyface As SlyFaceVolume, ByRef xyz() As Double) As Boolean
|
| 1088 |
|
|
Dim swface As SldWorks.Face2
|
| 1089 |
|
|
Dim surarete As Boolean
|
| 1090 |
|
|
For Each swface In Slyface.lst_Faces
|
| 1091 |
|
|
If DetectFaceArete(swArete, swface, xyz) Then
|
| 1092 |
|
|
Dim vEdges As Object
|
| 1093 |
|
|
Dim Arete As SldWorks.Edge
|
| 1094 |
|
|
Dim inu() As Double = Nothing
|
| 1095 |
|
|
|
| 1096 |
|
|
vEdges = swface.GetEdges
|
| 1097 |
|
|
|
| 1098 |
|
|
For Each Arete In vEdges
|
| 1099 |
|
|
If DetectAreteArete(Arete, swArete, inu) Then
|
| 1100 |
|
|
' on a un type d'intersection entre une face et une arète...
|
| 1101 |
|
|
Dim swSurf As SldWorks.Surface
|
| 1102 |
|
|
Dim retval As Object
|
| 1103 |
|
|
Dim v(2) As Double
|
| 1104 |
|
|
Dim u(2) As Double
|
| 1105 |
|
|
Dim angle As Double
|
| 1106 |
|
|
swSurf = swface.GetSurface
|
| 1107 |
|
|
retval = swSurf.EvaluateAtPoint(xyz(0), xyz(1), xyz(2))
|
| 1108 |
|
|
' les 3 premiers de retval sont la normale...
|
| 1109 |
|
|
v(0) = retval(0) : v(1) = retval(1) : v(2) = retval(2)
|
| 1110 |
|
|
|
| 1111 |
|
|
retval = swArete.GetParameter(inu(0), inu(1), inu(2))
|
| 1112 |
|
|
retval = swArete.Evaluate(retval(0))
|
| 1113 |
|
|
u(0) = retval(3) : u(1) = retval(4) : u(2) = retval(5)
|
| 1114 |
|
|
angle = Outils_Math.Angle2Vecteurs(u, v)
|
| 1115 |
|
|
MsgBox(angle * 180 / Pi & "<-- angle sens --> " & swface.FaceInSurfaceSense)
|
| 1116 |
|
|
|
| 1117 |
|
|
If ((angle < (Pi / 2)) Xor swface.FaceInSurfaceSense()) Then
|
| 1118 |
|
|
Return True
|
| 1119 |
|
|
Else
|
| 1120 |
|
|
surarete = True
|
| 1121 |
|
|
End If
|
| 1122 |
|
|
End If
|
| 1123 |
|
|
Next
|
| 1124 |
|
|
|
| 1125 |
|
|
|
| 1126 |
|
|
If Not surarete Then Return True Else Return False
|
| 1127 |
|
|
End If
|
| 1128 |
|
|
Next
|
| 1129 |
|
|
End Function
|
| 1130 |
|
|
|
| 1131 |
|
|
|
| 1132 |
|
|
|
| 1133 |
|
|
|
| 1134 |
|
|
Private Function DetectSurfaceArete(ByRef swArete As SldWorks.Edge, ByRef swFace As SldWorks.Face2, ByRef xyz() As Double) As Boolean
|
| 1135 |
|
|
' function qui détecte si une arête coupe une face, si c'est le cas la function retourne true et remplie le tableau xyz avec le point d'intersection
|
| 1136 |
|
|
Dim swCurve As SldWorks.Curve
|
| 1137 |
|
|
Dim swSurf As SldWorks.Surface
|
| 1138 |
|
|
Dim vCurveParam As Object
|
| 1139 |
|
|
|
| 1140 |
|
|
Dim vCurveBounds As Object, vPointArray As Object = Nothing, vTArray As Object = Nothing, vUVArray As Object = Nothing
|
| 1141 |
|
|
Dim nCurveBounds(5) As Double
|
| 1142 |
|
|
Dim bRet As Boolean
|
| 1143 |
|
|
Dim i As Integer
|
| 1144 |
|
|
|
| 1145 |
|
|
'1 - on va chercher la courbe et la surface
|
| 1146 |
|
|
swCurve = swArete.GetCurve
|
| 1147 |
|
|
swSurf = swFace.GetSurface
|
| 1148 |
|
|
|
| 1149 |
|
|
|
| 1150 |
|
|
' 2- on va chercher les paramètres de la spline avec Curve::ConvertLineToBcurve
|
| 1151 |
|
|
vCurveParam = swArete.GetCurveParams2
|
| 1152 |
|
|
If swCurve.IsLine Then
|
| 1153 |
|
|
Dim startp(2) As Double
|
| 1154 |
|
|
Dim endp(2) As Double
|
| 1155 |
|
|
Dim vStart As Object
|
| 1156 |
|
|
Dim vEnd As Object
|
| 1157 |
|
|
|
| 1158 |
|
|
|
| 1159 |
|
|
startp(0) = vCurveParam(0)
|
| 1160 |
|
|
startp(1) = vCurveParam(1)
|
| 1161 |
|
|
startp(2) = vCurveParam(2)
|
| 1162 |
|
|
vStart = startp
|
| 1163 |
|
|
|
| 1164 |
|
|
endp(0) = vCurveParam(3)
|
| 1165 |
|
|
endp(1) = vCurveParam(4)
|
| 1166 |
|
|
endp(2) = vCurveParam(5)
|
| 1167 |
|
|
vEnd = endp
|
| 1168 |
|
|
|
| 1169 |
|
|
Dim retval As Object
|
| 1170 |
|
|
|
| 1171 |
|
|
retval = swCurve.ConvertLineToBcurve(vStart, vEnd)
|
| 1172 |
|
|
|
| 1173 |
|
|
' on suppose que la droite est toujours transformée en spline non-rationelle de dimension 3 et d'ordre 2
|
| 1174 |
|
|
Dim knots(3) As Double
|
| 1175 |
|
|
Dim ctrlPoints(5) As Double
|
| 1176 |
|
|
|
| 1177 |
|
|
knots(0) = retval(2)
|
| 1178 |
|
|
knots(1) = retval(3)
|
| 1179 |
|
|
knots(2) = retval(4)
|
| 1180 |
|
|
knots(3) = retval(5)
|
| 1181 |
|
|
|
| 1182 |
|
|
ctrlPoints(0) = retval(6)
|
| 1183 |
|
|
ctrlPoints(1) = retval(7)
|
| 1184 |
|
|
ctrlPoints(2) = retval(8)
|
| 1185 |
|
|
ctrlPoints(3) = retval(9)
|
| 1186 |
|
|
ctrlPoints(4) = retval(10)
|
| 1187 |
|
|
ctrlPoints(5) = retval(11)
|
| 1188 |
|
|
|
| 1189 |
|
|
'3 - on créé une spline dans le modeleur
|
| 1190 |
|
|
|
| 1191 |
|
|
|
| 1192 |
|
|
Dim modeler As SldWorks.Modeler
|
| 1193 |
|
|
modeler = swApp.GetModeler
|
| 1194 |
|
|
Dim props As Object
|
| 1195 |
|
|
Dim dProps(1) As Double
|
| 1196 |
|
|
Dim vKnots As Object, vCtrlPoints As Object
|
| 1197 |
|
|
|
| 1198 |
|
|
dProps(0) = retval(0)
|
| 1199 |
|
|
dProps(1) = retval(1)
|
| 1200 |
|
|
props = dProps
|
| 1201 |
|
|
vKnots = knots
|
| 1202 |
|
|
vCtrlPoints = ctrlPoints
|
| 1203 |
|
|
|
| 1204 |
|
|
swCurve = modeler.CreateBsplineCurve(props, vKnots, vCtrlPoints)
|
| 1205 |
|
|
' 4 - on a une spline, on peut utiliser la fonction IntersectCurve
|
| 1206 |
|
|
End If
|
| 1207 |
|
|
|
| 1208 |
|
|
|
| 1209 |
|
|
For i = 0 To 5
|
| 1210 |
|
|
nCurveBounds(i) = vCurveParam(i)
|
| 1211 |
|
|
Next i
|
| 1212 |
|
|
|
| 1213 |
|
|
vCurveBounds = nCurveBounds
|
| 1214 |
|
|
bRet = swSurf.IntersectCurve(swCurve, vCurveBounds, vPointArray, vTArray, vUVArray)
|
| 1215 |
|
|
|
| 1216 |
|
|
Dim Pts() As Double
|
| 1217 |
|
|
Dim PointsTemp() As Double = Nothing
|
| 1218 |
|
|
Dim j As Integer
|
| 1219 |
|
|
|
| 1220 |
|
|
Pts = vPointArray
|
| 1221 |
|
|
|
| 1222 |
|
|
If UBound(Pts) < 1 Then Return False
|
| 1223 |
|
|
|
| 1224 |
|
|
For i = 0 To UBound(Pts) - 1 Step 3
|
| 1225 |
|
|
ReDim Preserve PointsTemp(j + 2)
|
| 1226 |
|
|
PointsTemp(j) = Pts(i + 0)
|
| 1227 |
|
|
PointsTemp(j + 1) = Pts(i + 1)
|
| 1228 |
|
|
PointsTemp(j + 2) = Pts(i + 2)
|
| 1229 |
|
|
j += 3
|
| 1230 |
|
|
Next i
|
| 1231 |
|
|
|
| 1232 |
|
|
xyz = PointsTemp
|
| 1233 |
|
|
If xyz Is Nothing Then Return False
|
| 1234 |
|
|
If UBound(xyz) > 0 Then Return True
|
| 1235 |
|
|
|
| 1236 |
|
|
|
| 1237 |
|
|
End Function
|
| 1238 |
|
|
|
| 1239 |
|
|
|
| 1240 |
|
|
|
| 1241 |
|
|
Private Function DetectSommetArete(ByRef swsommet As SldWorks.Vertex, ByRef swArete As SldWorks.Edge, ByRef xyz() As Double) As Boolean
|
| 1242 |
|
|
Dim x As Double, y As Double, z As Double
|
| 1243 |
|
|
Dim vPoint As Object
|
| 1244 |
|
|
Dim vPoint2 As Object
|
| 1245 |
|
|
vPoint = swsommet.GetPoint
|
| 1246 |
|
|
|
| 1247 |
|
|
x = vPoint(0)
|
| 1248 |
|
|
y = vPoint(1)
|
| 1249 |
|
|
z = vPoint(2)
|
| 1250 |
|
|
|
| 1251 |
|
|
vPoint2 = swArete.GetClosestPointOn(x, y, z)
|
| 1252 |
|
|
If Math.Abs(vPoint2(0) - x) < Epsilon And Math.Abs(vPoint2(1) - y) < Epsilon And Math.Abs(vPoint2(2) - z) < Epsilon Then
|
| 1253 |
|
|
ReDim xyz(2)
|
| 1254 |
|
|
xyz(0) = x
|
| 1255 |
|
|
xyz(1) = y
|
| 1256 |
|
|
xyz(2) = z
|
| 1257 |
|
|
DetectSommetArete = True
|
| 1258 |
|
|
End If
|
| 1259 |
|
|
|
| 1260 |
|
|
End Function
|
| 1261 |
|
|
|
| 1262 |
|
|
|
| 1263 |
|
|
Private Function DetectSommetArete(ByRef x As Double, ByRef y As Double, ByRef z As Double, ByRef swArete As SldWorks.Edge) As Byte
|
| 1264 |
|
|
Dim vPoint As Object
|
| 1265 |
|
|
Dim vPoint2 As Object
|
| 1266 |
|
|
|
| 1267 |
|
|
vPoint2 = swArete.GetClosestPointOn(x, y, z)
|
| 1268 |
|
|
If Math.Abs(vPoint2(0) - x) < Epsilon And Math.Abs(vPoint2(1) - y) < Epsilon And Math.Abs(vPoint2(2) - z) < Epsilon Then
|
| 1269 |
|
|
DetectSommetArete = 1
|
| 1270 |
|
|
|
| 1271 |
|
|
' maintenant on cherche à savoir si ca touche au premier sommet de l'arrête.
|
| 1272 |
|
|
vPoint = swArete.GetCurveParams2()
|
| 1273 |
|
|
|
| 1274 |
|
|
If Math.Abs(vPoint(0) - x) < Epsilon And Math.Abs(vPoint(1) - y) < Epsilon And Math.Abs(vPoint(2) - z) < Epsilon Then DetectSommetArete = 2
|
| 1275 |
|
|
If Math.Abs(vPoint(3) - x) < Epsilon And Math.Abs(vPoint(4) - y) < Epsilon And Math.Abs(vPoint(5) - z) < Epsilon Then DetectSommetArete = 2
|
| 1276 |
|
|
|
| 1277 |
|
|
End If
|
| 1278 |
|
|
|
| 1279 |
|
|
End Function
|
| 1280 |
|
|
|
| 1281 |
|
|
Private Function DetectSommetArete(ByRef swArete2som As SldWorks.Edge, ByRef swArete As SldWorks.Edge, ByRef xyz() As Double, Optional ByRef ret As Byte = 0) As Boolean
|
| 1282 |
|
|
' ret: 1 = sur premier sommet, 2 = sur dernier sommet
|
| 1283 |
|
|
Dim x As Double, y As Double, z As Double
|
| 1284 |
|
|
Dim vPoint As Object
|
| 1285 |
|
|
Dim vPoint2 As Object
|
| 1286 |
|
|
Dim swSommet As SldWorks.Vertex
|
| 1287 |
|
|
|
| 1288 |
|
|
swSommet = swArete2som.GetStartVertex
|
| 1289 |
|
|
If IsNothing(swSommet) Then Exit Function ' on a un cercle...
|
| 1290 |
|
|
|
| 1291 |
|
|
|
| 1292 |
|
|
vPoint = swSommet.GetPoint
|
| 1293 |
|
|
|
| 1294 |
|
|
x = vPoint(0)
|
| 1295 |
|
|
y = vPoint(1)
|
| 1296 |
|
|
z = vPoint(2)
|
| 1297 |
|
|
|
| 1298 |
|
|
vPoint2 = swArete.GetClosestPointOn(x, y, z)
|
| 1299 |
|
|
If Math.Abs(vPoint2(0) - x) < Epsilon And Math.Abs(vPoint2(1) - y) < Epsilon And Math.Abs(vPoint2(2) - z) < Epsilon Then
|
| 1300 |
|
|
ReDim xyz(2)
|
| 1301 |
|
|
xyz(0) = x
|
| 1302 |
|
|
xyz(1) = y
|
| 1303 |
|
|
xyz(2) = z
|
| 1304 |
|
|
DetectSommetArete = True
|
| 1305 |
|
|
ret += 1
|
| 1306 |
|
|
End If
|
| 1307 |
|
|
|
| 1308 |
|
|
swSommet = swArete2som.GetEndVertex
|
| 1309 |
|
|
vPoint = swSommet.GetPoint
|
| 1310 |
|
|
|
| 1311 |
|
|
x = vPoint(0)
|
| 1312 |
|
|
y = vPoint(1)
|
| 1313 |
|
|
z = vPoint(2)
|
| 1314 |
|
|
|
| 1315 |
|
|
vPoint2 = swArete.GetClosestPointOn(x, y, z)
|
| 1316 |
|
|
If Math.Abs(vPoint2(0) - x) < Epsilon And Math.Abs(vPoint2(1) - y) < Epsilon And Math.Abs(vPoint2(2) - z) < Epsilon Then
|
| 1317 |
|
|
ReDim xyz(2)
|
| 1318 |
|
|
xyz(0) = x
|
| 1319 |
|
|
xyz(1) = y
|
| 1320 |
|
|
xyz(2) = z
|
| 1321 |
|
|
DetectSommetArete = True
|
| 1322 |
|
|
ret += 2
|
| 1323 |
|
|
End If
|
| 1324 |
|
|
|
| 1325 |
|
|
|
| 1326 |
|
|
End Function
|
| 1327 |
|
|
|
| 1328 |
|
|
Private Sub Memoriser3iemePoint()
|
| 1329 |
|
|
Dim poutre As SlyAretePoutre
|
| 1330 |
|
|
Dim attr As SldWorks.Attribute
|
| 1331 |
|
|
Dim p As SldWorks.Parameter
|
| 1332 |
|
|
Dim swEnt As SldWorks.Entity
|
| 1333 |
|
|
|
| 1334 |
|
|
|
| 1335 |
|
|
|
| 1336 |
|
|
For Each poutre In Commun.lst_AretePoutre
|
| 1337 |
|
|
Dim xyz() As Double
|
| 1338 |
|
|
Dim nom As String = Nothing
|
| 1339 |
|
|
|
| 1340 |
|
|
If Not poutre.IsFaceDeSection Then
|
| 1341 |
|
|
xyz = poutre.GetPoint3(nom)
|
| 1342 |
|
|
|
| 1343 |
|
|
poutre.X3 = xyz(0)
|
| 1344 |
|
|
poutre.Y3 = xyz(1)
|
| 1345 |
|
|
poutre.Z3 = xyz(2)
|
| 1346 |
|
|
|
| 1347 |
|
|
swEnt = poutre.swArete
|
| 1348 |
|
|
|
| 1349 |
|
|
attr = swEnt.FindAttribute(Intersections.DefAttrRCP1, 0)
|
| 1350 |
|
|
p = attr.GetParameter("N3")
|
| 1351 |
|
|
|
| 1352 |
|
|
p = attr.GetParameter("X3")
|
| 1353 |
|
|
p.SetDoubleValue2(poutre.X3, 2, "")
|
| 1354 |
|
|
|
| 1355 |
|
|
p = attr.GetParameter("Y3")
|
| 1356 |
|
|
p.SetDoubleValue2(poutre.Y3, 2, "")
|
| 1357 |
|
|
|
| 1358 |
|
|
p = attr.GetParameter("Z3")
|
| 1359 |
|
|
p.SetDoubleValue2(poutre.Z3, 2, "")
|
| 1360 |
|
|
End If
|
| 1361 |
|
|
Next poutre
|
| 1362 |
|
|
|
| 1363 |
|
|
End Sub
|
| 1364 |
|
|
|
| 1365 |
|
|
|
| 1366 |
|
|
|
| 1367 |
|
|
Private Sub CouperPoutres()
|
| 1368 |
|
|
|
| 1369 |
|
|
' procédure qui trouve les intersections entre les poutres et qui les coupe.
|
| 1370 |
|
|
' à la fin on a plus d'intersections entre les poutres (ailleur qu'un sommet)
|
| 1371 |
|
|
|
| 1372 |
|
|
Dim swArete1 As SldWorks.Edge
|
| 1373 |
|
|
Dim swArete2 As SldWorks.Edge
|
| 1374 |
|
|
Dim SlyArete1 As SlyAretePoutre
|
| 1375 |
|
|
Dim SlyArete2 As SlyAretePoutre
|
| 1376 |
|
|
|
| 1377 |
|
|
Dim xyz() As Double = Nothing
|
| 1378 |
|
|
Dim pt As New InterPoutrePoutre
|
| 1379 |
|
|
'Dim lst_pts As New Collection
|
| 1380 |
|
|
Dim i As Long
|
| 1381 |
|
|
|
| 1382 |
|
|
Dim a1 As Integer
|
| 1383 |
|
|
Dim a2 As Integer
|
| 1384 |
|
|
|
| 1385 |
|
|
|
| 1386 |
|
|
For a1 = 0 To lst_AretePoutre.Count - 2
|
| 1387 |
|
|
SlyArete1 = lst_AretePoutre.Item(a1)
|
| 1388 |
|
|
swArete1 = SlyArete1.swArete
|
| 1389 |
|
|
|
| 1390 |
|
|
For a2 = a1 + 1 To lst_AretePoutre.Count - 1
|
| 1391 |
|
|
SlyArete2 = lst_AretePoutre.Item(a2)
|
| 1392 |
|
|
swArete2 = SlyArete2.swArete
|
| 1393 |
|
|
|
| 1394 |
|
|
If DetectAreteArete(swArete1, swArete2, xyz) Then ' intersection courbe-courbe
|
| 1395 |
|
|
For i = 0 To CInt((UBound(xyz) + 1) / 4) Step 4 ' si y'a plus d'une intersection entre les 2 courbes...
|
| 1396 |
|
|
|
| 1397 |
|
|
Select Case isIntersect_milieu(swArete1, swArete2, xyz(i), xyz(i + 1), xyz(i + 2))
|
| 1398 |
|
|
Case 1 ' la première courbe est coupée
|
| 1399 |
|
|
pt = New InterPoutrePoutre
|
| 1400 |
|
|
pt.Arete = swArete1
|
| 1401 |
|
|
pt.x = xyz(i) : pt.y = xyz(i + 1) : pt.z = xyz(i + 2)
|
| 1402 |
|
|
SlyArete1.AjouterPointAPAP(pt)
|
| 1403 |
|
|
pt = Nothing
|
| 1404 |
|
|
Case 2 ' la seconde courbe est coupée
|
| 1405 |
|
|
pt = New InterPoutrePoutre
|
| 1406 |
|
|
pt.Arete = swArete2
|
| 1407 |
|
|
pt.x = xyz(i) : pt.y = xyz(i + 1) : pt.z = xyz(i + 2)
|
| 1408 |
|
|
SlyArete2.AjouterPointAPAP(pt)
|
| 1409 |
|
|
pt = Nothing
|
| 1410 |
|
|
Case 3 ' les doux poutres sont coupées
|
| 1411 |
|
|
pt = New InterPoutrePoutre
|
| 1412 |
|
|
pt.Arete = swArete1
|
| 1413 |
|
|
pt.x = xyz(i) : pt.y = xyz(i + 1) : pt.z = xyz(i + 2)
|
| 1414 |
|
|
SlyArete1.AjouterPointAPAP(pt)
|
| 1415 |
|
|
pt = Nothing
|
| 1416 |
|
|
pt = New InterPoutrePoutre
|
| 1417 |
|
|
pt.Arete = swArete2
|
| 1418 |
|
|
pt.x = xyz(i) : pt.y = xyz(i + 1) : pt.z = xyz(i + 2)
|
| 1419 |
|
|
SlyArete2.AjouterPointAPAP(pt)
|
| 1420 |
|
|
pt = Nothing
|
| 1421 |
|
|
End Select
|
| 1422 |
|
|
Next i
|
| 1423 |
|
|
End If
|
| 1424 |
|
|
|
| 1425 |
|
|
Next a2
|
| 1426 |
|
|
|
| 1427 |
|
|
Dim SlyArete3 As SlyAreteCoque
|
| 1428 |
|
|
For a2 = 0 To lst_AreteCoque.Count - 1
|
| 1429 |
|
|
SlyArete3 = lst_AreteCoque.Item(a2)
|
| 1430 |
|
|
swArete2 = SlyArete3.swArete
|
| 1431 |
|
|
|
| 1432 |
|
|
If DetectAreteArete(swArete1, swArete2, xyz) Then ' intersection courbe-courbe
|
| 1433 |
|
|
For i = 0 To CInt((UBound(xyz) + 1) / 4) Step 4 ' si y'a plus d'une intersection entre les 2 courbes...
|
| 1434 |
|
|
|
| 1435 |
|
|
Select Case isIntersect_milieu(swArete1, swArete2, xyz(i), xyz(i + 1), xyz(i + 2))
|
| 1436 |
|
|
Case 1 ' la première courbe est coupée
|
| 1437 |
|
|
pt = New InterPoutrePoutre
|
| 1438 |
|
|
pt.Arete = swArete1
|
| 1439 |
|
|
pt.x = xyz(i) : pt.y = xyz(i + 1) : pt.z = xyz(i + 2)
|
| 1440 |
|
|
SlyArete1.AjouterPointAPAP(pt)
|
| 1441 |
|
|
pt = Nothing
|
| 1442 |
|
|
' seul la coque est coupée, elle sera découpée anyway.
|
| 1443 |
|
|
Case 3 ' les doux poutres sont coupées, mais on note juste la deuxième
|
| 1444 |
|
|
pt = New InterPoutrePoutre
|
| 1445 |
|
|
pt.Arete = swArete1
|
| 1446 |
|
|
pt.x = xyz(i) : pt.y = xyz(i + 1) : pt.z = xyz(i + 2)
|
| 1447 |
|
|
SlyArete1.AjouterPointAPAP(pt)
|
| 1448 |
|
|
pt = Nothing
|
| 1449 |
|
|
End Select
|
| 1450 |
|
|
Next i
|
| 1451 |
|
|
End If
|
| 1452 |
|
|
Next a2
|
| 1453 |
|
|
|
| 1454 |
|
|
Dim slyarete4 As SlyAreteVol
|
| 1455 |
|
|
For a2 = 0 To lst_AreteVolume.Count - 1
|
| 1456 |
|
|
slyarete4 = lst_AreteVolume.Item(a2)
|
| 1457 |
|
|
swArete2 = slyarete4.swArete
|
| 1458 |
|
|
|
| 1459 |
|
|
If DetectAreteArete(swArete1, swArete2, xyz) Then ' intersection courbe-courbe
|
| 1460 |
|
|
For i = 0 To CInt((UBound(xyz) + 1) / 4) Step 4 ' si y'a plus d'une intersection entre les 2 courbes...
|
| 1461 |
|
|
|
| 1462 |
|
|
Select Case isIntersect_milieu(swArete1, swArete2, xyz(i), xyz(i + 1), xyz(i + 2))
|
| 1463 |
|
|
Case 1 ' la première courbe est coupée
|
| 1464 |
|
|
pt = New InterPoutrePoutre
|
| 1465 |
|
|
pt.Arete = swArete1
|
| 1466 |
|
|
pt.x = xyz(i) : pt.y = xyz(i + 1) : pt.z = xyz(i + 2)
|
| 1467 |
|
|
SlyArete1.AjouterPointAPAP(pt)
|
| 1468 |
|
|
pt = Nothing
|
| 1469 |
|
|
Case 3 ' les doux poutres sont coupées, mais on note juste la deuxième
|
| 1470 |
|
|
pt = New InterPoutrePoutre
|
| 1471 |
|
|
pt.Arete = swArete1
|
| 1472 |
|
|
pt.x = xyz(i) : pt.y = xyz(i + 1) : pt.z = xyz(i + 2)
|
| 1473 |
|
|
SlyArete1.AjouterPointAPAP(pt)
|
| 1474 |
|
|
pt = Nothing
|
| 1475 |
|
|
End Select
|
| 1476 |
|
|
Next i
|
| 1477 |
|
|
End If
|
| 1478 |
|
|
Next a2
|
| 1479 |
|
|
|
| 1480 |
|
|
|
| 1481 |
|
|
|
| 1482 |
|
|
Next a1
|
| 1483 |
|
|
pt = Nothing
|
| 1484 |
|
|
|
| 1485 |
|
|
|
| 1486 |
|
|
|
| 1487 |
|
|
'toutes les poutres ont des points où elles doivent être coupées
|
| 1488 |
|
|
' il suffit de couper.
|
| 1489 |
|
|
' en réalité on suppress et on créé 2 ou plus courbes par dessus.
|
| 1490 |
|
|
Dim attr As SldWorks.Attribute
|
| 1491 |
|
|
Dim swEnt As SldWorks.Entity
|
| 1492 |
|
|
|
| 1493 |
|
|
For Each SlyArete1 In lst_AretePoutre
|
| 1494 |
|
|
If SlyArete1.lst_PtsInterAPAP.Count > 0 Then ' on coupe
|
| 1495 |
|
|
'1 - ordonner les points, de Tmin à Tmax et inclure les 2 extrémités de la poutre
|
| 1496 |
|
|
|
| 1497 |
|
|
|
| 1498 |
|
|
' si c'est une droite
|
| 1499 |
|
|
If SlyArete1.IsLine Then
|
| 1500 |
|
|
Dim Pts(,) As Double
|
| 1501 |
|
|
Dim swSketch As SldWorks.Sketch
|
| 1502 |
|
|
ReDim Pts(3, SlyArete1.lst_PtsInterAPAP.Count + 1)
|
| 1503 |
|
|
|
| 1504 |
|
|
SlyArete1.GetStartPoint(Pts(0, 0), Pts(1, 0), Pts(2, 0)) ' le premier point
|
| 1505 |
|
|
Pts(3, 0) = SlyArete1.GetT(Pts(0, 0), Pts(1, 0), Pts(2, 0))
|
| 1506 |
|
|
|
| 1507 |
|
|
For i = 1 To SlyArete1.lst_PtsInterAPAP.Count
|
| 1508 |
|
|
Pts(0, i) = SlyArete1.lst_PtsInterAPAP.Item(i).x
|
| 1509 |
|
|
Pts(1, i) = SlyArete1.lst_PtsInterAPAP.Item(i).y
|
| 1510 |
|
|
Pts(2, i) = SlyArete1.lst_PtsInterAPAP.Item(i).z
|
| 1511 |
|
|
Pts(3, i) = SlyArete1.GetT(Pts(0, i), Pts(1, i), Pts(2, i))
|
| 1512 |
|
|
Next i
|
| 1513 |
|
|
|
| 1514 |
|
|
Dim max As Integer = SlyArete1.lst_PtsInterAPAP.Count + 1
|
| 1515 |
|
|
SlyArete1.GetEndPoint(Pts(0, max), Pts(1, max), Pts(2, max)) ' le dernier point
|
| 1516 |
|
|
Pts(3, max) = SlyArete1.GetT(Pts(0, max), Pts(1, max), Pts(2, max))
|
| 1517 |
|
|
|
| 1518 |
|
|
' faut ordonner les points selon T...
|
| 1519 |
|
|
Dim j As Integer
|
| 1520 |
|
|
Dim T1 As Double, T2 As Double, T3 As Double, T0 As Double
|
| 1521 |
|
|
For i = 0 To max - 2
|
| 1522 |
|
|
For j = 0 To max - i - 1
|
| 1523 |
|
|
If Pts(3, j) > Pts(3, j + 1) Then
|
| 1524 |
|
|
T0 = Pts(0, j) : T1 = Pts(1, j) : T2 = Pts(2, j) : T3 = Pts(3, j)
|
| 1525 |
|
|
Pts(0, j) = Pts(0, j + 1) : Pts(1, j) = Pts(1, j + 1) : Pts(2, j) = Pts(2, j + 1) : Pts(3, j) = Pts(3, j + 1)
|
| 1526 |
|
|
Pts(0, j + 1) = T0 : Pts(1, j + 1) = T1 : Pts(2, j + 1) = T2 : Pts(3, j + 1) = T3
|
| 1527 |
|
|
End If
|
| 1528 |
|
|
Next j
|
| 1529 |
|
|
Next i
|
| 1530 |
|
|
|
| 1531 |
|
|
|
| 1532 |
|
|
For i = 0 To UBound(Pts, 2) - 1
|
| 1533 |
|
|
swModel.Insert3DSketch2(False)
|
| 1534 |
|
|
swModel.CreateLine2(Pts(0, i), Pts(1, i), Pts(2, i), Pts(0, i + 1), Pts(1, i + 1), Pts(2, i + 1)) ' et pour chaque segment
|
| 1535 |
|
|
swSketch = swModel.GetActiveSketch2
|
| 1536 |
|
|
swModel.Insert3DSketch2(False)
|
| 1537 |
|
|
|
| 1538 |
|
|
swEnt = swSketch : swEnt.Select2(False, 1) ' doit avoir un mark de 1
|
| 1539 |
|
|
swModel.InsertCompositeCurve()
|
| 1540 |
|
|
|
| 1541 |
|
|
UpdateAttributs(SlyArete1, i) 'ajouter les attributs de la vieille poutre sur la nouvelle
|
| 1542 |
|
|
Next i
|
| 1543 |
|
|
|
| 1544 |
|
|
|
| 1545 |
|
|
Else ' If SlyArete1.IsCircle Then ' si c'est un cercle
|
| 1546 |
|
|
|
| 1547 |
|
|
Dim Pts(,) As Double
|
| 1548 |
|
|
Dim swSketch As SldWorks.Sketch
|
| 1549 |
|
|
ReDim Pts(3, SlyArete1.lst_PtsInterAPAP.Count + 1)
|
| 1550 |
|
|
|
| 1551 |
|
|
SlyArete1.GetStartPoint(Pts(0, 0), Pts(1, 0), Pts(2, 0)) ' le premier point
|
| 1552 |
|
|
Pts(3, 0) = SlyArete1.GetT(Pts(0, 0), Pts(1, 0), Pts(2, 0))
|
| 1553 |
|
|
|
| 1554 |
|
|
For i = 1 To SlyArete1.lst_PtsInterAPAP.Count
|
| 1555 |
|
|
Pts(0, i) = SlyArete1.lst_PtsInterAPAP.Item(i).x
|
| 1556 |
|
|
Pts(1, i) = SlyArete1.lst_PtsInterAPAP.Item(i).y
|
| 1557 |
|
|
Pts(2, i) = SlyArete1.lst_PtsInterAPAP.Item(i).z
|
| 1558 |
|
|
Pts(3, i) = SlyArete1.GetT(Pts(0, i), Pts(1, i), Pts(2, i))
|
| 1559 |
|
|
Next i
|
| 1560 |
|
|
|
| 1561 |
|
|
Dim max As Integer = SlyArete1.lst_PtsInterAPAP.Count + 1
|
| 1562 |
|
|
SlyArete1.GetEndPoint(Pts(0, max), Pts(1, max), Pts(2, max)) ' le dernier point
|
| 1563 |
|
|
Pts(3, max) = SlyArete1.GetT(Pts(0, max), Pts(1, max), Pts(2, max))
|
| 1564 |
|
|
|
| 1565 |
|
|
' faut ordonner les points selon T...
|
| 1566 |
|
|
Dim j As Integer
|
| 1567 |
|
|
Dim T1 As Double, T2 As Double, T3 As Double, T0 As Double
|
| 1568 |
|
|
For i = 0 To max - 2
|
| 1569 |
|
|
For j = 0 To max - i - 1
|
| 1570 |
|
|
If Pts(3, j) > Pts(3, j + 1) Then
|
| 1571 |
|
|
T0 = Pts(0, j) : T1 = Pts(1, j) : T2 = Pts(2, j) : T3 = Pts(3, j)
|
| 1572 |
|
|
Pts(0, j) = Pts(0, j + 1) : Pts(1, j) = Pts(1, j + 1) : Pts(2, j) = Pts(2, j + 1) : Pts(3, j) = Pts(3, j + 1)
|
| 1573 |
|
|
Pts(0, j + 1) = T0 : Pts(1, j + 1) = T1 : Pts(2, j + 1) = T2 : Pts(3, j + 1) = T3
|
| 1574 |
|
|
End If
|
| 1575 |
|
|
Next j
|
| 1576 |
|
|
Next i
|
| 1577 |
|
|
|
| 1578 |
|
|
Dim skSeg As SldWorks.SketchSegment
|
| 1579 |
|
|
Dim x As Double, y As Double, z As Double
|
| 1580 |
|
|
Dim vretval As Object
|
| 1581 |
|
|
Dim useEdge As SldWorks.SketchSegment
|
| 1582 |
|
|
Dim m As Integer
|
| 1583 |
|
|
|
| 1584 |
|
|
|
| 1585 |
|
|
For i = 0 To UBound(Pts, 2) - 1
|
| 1586 |
|
|
swModel.Insert3DSketch2(False)
|
| 1587 |
|
|
' sélectionner la edge originale
|
| 1588 |
|
|
swEnt = SlyArete1.swArete
|
| 1589 |
|
|
swEnt.Select4(False, Nothing)
|
| 1590 |
|
|
swModel.SketchUseEdge2(False)
|
| 1591 |
|
|
swSketch = swModel.GetActiveSketch2()
|
| 1592 |
|
|
|
| 1593 |
|
|
' on créé 2 lignes de construction et on pick de chaque coté... mais on ne le fait pas si on est au premier ou au dernier segment. là on fait juste un pick.
|
| 1594 |
|
|
If i <> 0 Then ' premier pick, élimine ce qui est avant.
|
| 1595 |
|
|
skSeg = swModel.CreateLine2(Pts(0, i), Pts(1, i), Pts(2, i), 0.01, 0.01, 0.01) 'pts(0, i - 1) + 10000000 * Epsilon, pts(1, i - 1) + 100000 * Epsilon, pts(2, i - 1) + 100000 * Epsilon)
|
| 1596 |
|
|
skSeg.ConstructionGeometry = True ' ligne de construction
|
| 1597 |
|
|
swModel.ClearSelection2(True)
|
| 1598 |
|
|
' x et y doit être sélectionné sur un point avec un T inférieur au point d'intersection
|
| 1599 |
|
|
SlyArete1.Evaluer((Pts(3, i - 1) + Pts(3, i)) / 2, x, y, z)
|
| 1600 |
|
|
vretval = swSketch.GetSketchSegments
|
| 1601 |
|
|
useEdge = vretval(0) : m = 0
|
| 1602 |
|
|
Do Until useEdge.ConstructionGeometry = False
|
| 1603 |
|
|
m += 1
|
| 1604 |
|
|
useEdge = vretval(m)
|
| 1605 |
|
|
Loop
|
| 1606 |
|
|
useEdge.Select4(False, Nothing)
|
| 1607 |
|
|
swModel.SketchTrim(1, 0, x, y) ' option = 1 pour trim, selEnd est pas utilisé ?, puis un point x et Y pour sélectionner. et y'a pas de Z????? c'est un sketch3D!!!!!
|
| 1608 |
|
|
skSeg = swModel.CreateLine2(0, 0, 0, x, y, 0)
|
| 1609 |
|
|
skSeg.ConstructionGeometry = True
|
| 1610 |
|
|
End If
|
| 1611 |
|
|
|
| 1612 |
|
|
If i <> UBound(Pts, 2) - 1 Then 'Second(pick)
|
| 1613 |
|
|
skSeg = swModel.CreateLine2(Pts(0, i + 1), Pts(1, i + 1), Pts(2, i + 1), 0.05, 0, 0.01) 'pts(0, i + 1) + 10000000 * Epsilon, pts(1, i + 1) + 1000000 * Epsilon, pts(2, i + 1) + 100000 * Epsilon)
|
| 1614 |
|
|
skSeg.ConstructionGeometry = True ' ligne de construction
|
| 1615 |
|
|
swModel.ClearSelection2(True)
|
| 1616 |
|
|
|
| 1617 |
|
|
' x et y doit être sélectionné sur un point avec un T inférieur au point d'intersection
|
| 1618 |
|
|
SlyArete1.Evaluer((Pts(3, i + 1) + Pts(3, i + 2)) / 2, x, y, z)
|
| 1619 |
|
|
vretval = swSketch.GetSketchSegments
|
| 1620 |
|
|
useEdge = vretval(0) : m = 0
|
| 1621 |
|
|
Do Until useEdge.ConstructionGeometry = False
|
| 1622 |
|
|
m += 1
|
| 1623 |
|
|
useEdge = vretval(m)
|
| 1624 |
|
|
Loop
|
| 1625 |
|
|
|
| 1626 |
|
|
useEdge.Select4(False, Nothing)
|
| 1627 |
|
|
swModel.SketchTrim(1, 0, x, y) ' option = 1 pour trim, selEnd est pas utilisé ?, puis un point x et Y pour sélectionner. et y'a pas de Z????? c'est un sketch3D!!!!!
|
| 1628 |
|
|
skSeg = swModel.CreateLine2(0, 0.02, 0, x, y, 0)
|
| 1629 |
|
|
skSeg.ConstructionGeometry = True
|
| 1630 |
|
|
End If
|
| 1631 |
|
|
|
| 1632 |
|
|
swModel.Insert3DSketch2(False)
|
| 1633 |
|
|
swEnt = swSketch : swEnt.Select2(False, 1) ' doit avoir un mark de 1
|
| 1634 |
|
|
swModel.InsertCompositeCurve()
|
| 1635 |
|
|
UpdateAttributs(SlyArete1, i)
|
| 1636 |
|
|
Next i
|
| 1637 |
|
|
|
| 1638 |
|
|
End If
|
| 1639 |
|
|
|
| 1640 |
|
|
' tagger la vieille poutre pour ne pas la reprendre dans magic
|
| 1641 |
|
|
'Pour ça on ajoute un attribut pour ignorer...
|
| 1642 |
|
|
Dim nom As String
|
| 1643 |
|
|
Dim no As Integer
|
| 1644 |
|
|
Dim arete As SldWorks.Edge
|
| 1645 |
|
|
|
| 1646 |
|
|
arete = SlyArete1.swArete
|
| 1647 |
|
|
swEnt = arete
|
| 1648 |
|
|
nom = "Ignorer" & SlyArete1.nom & "_" & CStr(no)
|
| 1649 |
|
|
attr = swEnt.FindAttribute(Intersections.DefAttrRCP1, 0)
|
| 1650 |
|
|
'attr = DefAttrRCP1.CreateInstance5(swModel, arete, nom, 0, 2) ' une deuxième instance du RCPoutre...
|
| 1651 |
|
|
If attr Is Nothing Then
|
| 1652 |
|
|
Commun.ColorerAretes()
|
| 1653 |
|
|
swEnt = SlyArete1.swArete
|
| 1654 |
|
|
attr = swEnt.FindAttribute(Intersections.DefAttrRCP1, 0)
|
| 1655 |
|
|
End If
|
| 1656 |
|
|
|
| 1657 |
|
|
Dim p As SldWorks.Parameter
|
| 1658 |
|
|
p = attr.GetParameter("D1")
|
| 1659 |
|
|
p.SetDoubleValue(-9)
|
| 1660 |
|
|
p = attr.GetParameter("D2")
|
| 1661 |
|
|
p.SetDoubleValue(-9)
|
| 1662 |
|
|
p = attr.GetParameter("D3")
|
| 1663 |
|
|
p.SetDoubleValue(-9)
|
| 1664 |
|
|
p = attr.GetParameter("D4")
|
| 1665 |
|
|
p.SetDoubleValue(-9)
|
| 1666 |
|
|
|
| 1667 |
|
|
If attr Is Nothing Then MsgBox("Pas marché")
|
| 1668 |
|
|
|
| 1669 |
|
|
|
| 1670 |
|
|
End If
|
| 1671 |
|
|
Next SlyArete1
|
| 1672 |
|
|
|
| 1673 |
|
|
|
| 1674 |
|
|
End Sub
|
| 1675 |
|
|
|
| 1676 |
|
|
|
| 1677 |
|
|
Private Sub UpdateAttributs(ByRef slyarete1 As SlyAretePoutre, ByRef i As Integer)
|
| 1678 |
|
|
Dim newArete As SldWorks.Edge
|
| 1679 |
|
|
Dim refcurve As SldWorks.ReferenceCurve
|
| 1680 |
|
|
Dim attr As SldWorks.Attribute
|
| 1681 |
|
|
Dim swfeat As SldWorks.Feature
|
| 1682 |
|
|
|
| 1683 |
|
|
swfeat = swModel.FeatureByPositionReverse(0)
|
| 1684 |
|
|
|
| 1685 |
|
|
refcurve = swfeat.GetSpecificFeature2()
|
| 1686 |
|
|
newArete = refcurve.GetFirstSegment()
|
| 1687 |
|
|
|
| 1688 |
|
|
Dim ParamM As SldWorks.Parameter
|
| 1689 |
|
|
Dim ParamS As SldWorks.Parameter
|
| 1690 |
|
|
Dim ParamI1 As SldWorks.Parameter
|
| 1691 |
|
|
Dim ParamI2 As SldWorks.Parameter
|
| 1692 |
|
|
Dim ParamD1 As SldWorks.Parameter
|
| 1693 |
|
|
Dim ParamD2 As SldWorks.Parameter
|
| 1694 |
|
|
Dim ParamD3 As SldWorks.Parameter
|
| 1695 |
|
|
Dim ParamD4 As SldWorks.Parameter
|
| 1696 |
|
|
Dim ParamD5 As SldWorks.Parameter
|
| 1697 |
|
|
Dim ParamD6 As SldWorks.Parameter
|
| 1698 |
|
|
Dim ParamAs As SldWorks.Parameter
|
| 1699 |
|
|
Dim ParamN3 As SldWorks.Parameter
|
| 1700 |
|
|
|
| 1701 |
|
|
attr = Intersections.DefAttrRCP1.CreateInstance5(swModel, newArete, "Nouveau" & i & slyarete1.nom, 0, 2)
|
| 1702 |
|
|
|
| 1703 |
|
|
ParamM = attr.GetParameter("M")
|
| 1704 |
|
|
ParamS = attr.GetParameter("S")
|
| 1705 |
|
|
ParamI1 = attr.GetParameter("I1")
|
| 1706 |
|
|
ParamI2 = attr.GetParameter("I2")
|
| 1707 |
|
|
ParamD1 = attr.GetParameter("D1")
|
| 1708 |
|
|
ParamD2 = attr.GetParameter("D2")
|
| 1709 |
|
|
ParamD3 = attr.GetParameter("D3")
|
| 1710 |
|
|
ParamD4 = attr.GetParameter("D4")
|
| 1711 |
|
|
ParamD5 = attr.GetParameter("D5")
|
| 1712 |
|
|
ParamD6 = attr.GetParameter("D6")
|
| 1713 |
|
|
ParamAs = attr.GetParameter("As")
|
| 1714 |
|
|
|
| 1715 |
|
|
ParamM.SetStringValue2(slyarete1.GetM, 2, "") ' swAllConfiguration = 2
|
| 1716 |
|
|
ParamS.SetStringValue2(slyarete1.GetSection, 2, "")
|
| 1717 |
|
|
ParamI1.SetDoubleValue2(slyarete1.GetInertieXX, 2, "")
|
| 1718 |
|
|
ParamI2.SetDoubleValue2(slyarete1.GetInertieYY, 2, "")
|
| 1719 |
|
|
ParamD1.SetDoubleValue2(slyarete1.GetD1, 2, "")
|
| 1720 |
|
|
ParamD2.SetDoubleValue2(slyarete1.GetD2, 2, "")
|
| 1721 |
|
|
ParamD3.SetDoubleValue2(slyarete1.GetD3, 2, "")
|
| 1722 |
|
|
ParamD4.SetDoubleValue2(slyarete1.GetD4, 2, "")
|
| 1723 |
|
|
ParamD5.SetDoubleValue2(slyarete1.GetD5, 2, "")
|
| 1724 |
|
|
ParamD6.SetDoubleValue2(slyarete1.GetD6, 2, "")
|
| 1725 |
|
|
ParamAs.SetDoubleValue2(slyarete1.GetAireSection, 2, "")
|
| 1726 |
|
|
|
| 1727 |
|
|
Dim p As SldWorks.Parameter
|
| 1728 |
|
|
p = attr.GetParameter("N3")
|
| 1729 |
|
|
p.SetStringValue(slyarete1.GetN3)
|
| 1730 |
|
|
p = attr.GetParameter("X3")
|
| 1731 |
|
|
p.SetDoubleValue2(slyarete1.X3, 2, "")
|
| 1732 |
|
|
p = attr.GetParameter("Y3")
|
| 1733 |
|
|
p.SetDoubleValue2(slyarete1.Y3, 2, "")
|
| 1734 |
|
|
p = attr.GetParameter("Z3")
|
| 1735 |
|
|
p.SetDoubleValue2(slyarete1.Z3, 2, "")
|
| 1736 |
|
|
|
| 1737 |
|
|
Commun.GererDossiers("Poutres", "Nouveau" & i & slyarete1.nom)
|
| 1738 |
|
|
|
| 1739 |
|
|
End Sub
|
| 1740 |
|
|
|
| 1741 |
|
|
|
| 1742 |
|
|
|
| 1743 |
|
|
|
| 1744 |
|
|
''' <summary>
|
| 1745 |
|
|
''' sub qui gère la détection des intersections entre les coques et les volumes.
|
| 1746 |
|
|
''' </summary>
|
| 1747 |
|
|
''' <remarks></remarks>
|
| 1748 |
|
|
Private Sub DetectionCoqueVolume()
|
| 1749 |
|
|
|
| 1750 |
|
|
' détection de coque-coque
|
| 1751 |
|
|
Dim Face1 As SlyFaceVolume
|
| 1752 |
|
|
Dim coque2 As SlyFaceCoque
|
| 1753 |
|
|
Dim sketch As SldWorks.Sketch = Nothing
|
| 1754 |
|
|
Dim interFF As InterCoqueVolume
|
| 1755 |
|
|
|
| 1756 |
|
|
For Each Face1 In Commun.lst_FaceVolume
|
| 1757 |
|
|
For Each coque2 In lst_FaceCoque
|
| 1758 |
|
|
|
| 1759 |
|
|
If DetectFaceFace(coque2, Face1, True, sketch) Then
|
| 1760 |
|
|
' création de l'instance de interFace-face entre coque et coque
|
| 1761 |
|
|
|
| 1762 |
|
|
|
| 1763 |
|
|
interFF = New InterCoqueVolume
|
| 1764 |
|
|
interFF.sFaceVolume = Face1
|
| 1765 |
|
|
interFF.sFaceCoque = coque2
|
| 1766 |
|
|
If coque2.PossedeFaceDeSection = True Then
|
| 1767 |
|
|
interFF.FaceDeSection = True
|
| 1768 |
|
|
Verifier_Coque_Section(interFF)
|
| 1769 |
|
|
Else
|
| 1770 |
|
|
interFF.FaceDeSection = False
|
| 1771 |
|
|
End If
|
| 1772 |
|
|
interFF.sketch = sketch
|
| 1773 |
|
|
coque2.lst_InterCoqueVolume.Add(interFF)
|
| 1774 |
|
|
End If
|
| 1775 |
|
|
|
| 1776 |
|
|
Next
|
| 1777 |
|
|
Next
|
| 1778 |
|
|
|
| 1779 |
|
|
|
| 1780 |
|
|
|
| 1781 |
|
|
|
| 1782 |
|
|
End Sub
|
| 1783 |
|
|
|
| 1784 |
|
|
''' <summary>
|
| 1785 |
|
|
''' Sub qui fait les 6 vérifications pour le type d'intersection où la coque est partiellement dessinée en 3D.
|
| 1786 |
|
|
''' En profite également pour remettre à jour la proriété de l'épaisseur de la coque
|
| 1787 |
|
|
''' </summary>
|
| 1788 |
|
|
''' <param name="interFF">L'intersection</param>
|
| 1789 |
|
|
''' <remarks>On fait au total 6 vérifications</remarks>
|
| 1790 |
|
|
Private Sub Verifier_Coque_Section(ByRef interFF As InterCoqueVolume)
|
| 1791 |
|
|
Dim sFaceCoque As SlyFaceCoque
|
| 1792 |
|
|
Dim sFaceVol As SlyFaceVolume
|
| 1793 |
|
|
Dim swFace1 As SldWorks.Face2
|
| 1794 |
|
|
Dim swent As SldWorks.Entity
|
| 1795 |
|
|
|
| 1796 |
|
|
sFaceCoque = interFF.sFaceCoque
|
| 1797 |
|
|
sFaceVol = interFF.sFaceVolume
|
| 1798 |
|
|
|
| 1799 |
|
|
' 1 - vérifier que la face du volume est plane
|
| 1800 |
|
|
If Not sFaceVol.estPlan Then
|
| 1801 |
|
|
Err.Raise(513, "Verifier_Coque_Section", "La face représentant la section de la coque n'est pas plane...")
|
| 1802 |
|
|
End If
|
| 1803 |
|
|
|
| 1804 |
|
|
' 1.5 - La face du volume a 4 courbes, 2 petites de même longueur et 2 longues
|
| 1805 |
|
|
' 1.6 ou qu'elle est une courbe fermée avec 2 loop d'une seule arète chaque.
|
| 1806 |
|
|
Dim vEdges As Object
|
| 1807 |
|
|
Dim Aretes() As SldWorks.Edge
|
| 1808 |
|
|
Dim longueur(3) As Double
|
| 1809 |
|
|
Dim i As Integer
|
| 1810 |
|
|
Dim a As SldWorks.Edge
|
| 1811 |
|
|
ReDim Aretes(0)
|
| 1812 |
|
|
|
| 1813 |
|
|
swFace1 = sFaceVol.SwFace
|
| 1814 |
|
|
|
| 1815 |
|
|
vEdges = swFace1.GetEdges()
|
| 1816 |
|
|
For Each a In vEdges
|
| 1817 |
|
|
ReDim Preserve Aretes(i)
|
| 1818 |
|
|
Aretes(i) = a
|
| 1819 |
|
|
i += 1
|
| 1820 |
|
|
Next
|
| 1821 |
|
|
|
| 1822 |
|
|
If UBound(Aretes) = 3 Then
|
| 1823 |
|
|
For i = 0 To 3
|
| 1824 |
|
|
longueur(i) = Commun.GetLongueurArete(Aretes(i))
|
| 1825 |
|
|
Next i
|
| 1826 |
|
|
longueur = Ordonner(longueur, Aretes)
|
| 1827 |
|
|
If Not Math.Abs(longueur(0) - longueur(1)) < Epsilon Then
|
| 1828 |
|
|
swent = swFace1 : swent.Select2(False, 0)
|
| 1829 |
|
|
Err.Raise(514, "Verifier_Coque_Section", "La face du volume représentant la coque n'a pas 2 petites arètes de la même longueur, ce n'est pas normal. La face a problème a été sélectionée")
|
| 1830 |
|
|
End If
|
| 1831 |
|
|
|
| 1832 |
|
|
ElseIf UBound(Aretes) = 1 Then ' la coque représente un cylindre (ou un autre truc fermé)
|
| 1833 |
|
|
If Not swFace1.GetLoopCount = 2 Then
|
| 1834 |
|
|
swent = swFace1 : swent.Select2(False, 0)
|
| 1835 |
|
|
Err.Raise(514, "Verifier_Coque_Section", "La face du volume représentant la coque n'a pas 2 ou 4 arêtes ou n'est pas correcte... La face a problème a été sélectionée")
|
| 1836 |
|
|
End If
|
| 1837 |
|
|
Else
|
| 1838 |
|
|
swent = swFace1 : swent.Select2(False, 0)
|
| 1839 |
|
|
Err.Raise(514, "Verifier_Coque_Section", "La face du volume représentant la coque n'a pas 2 ou 4 arêtes. La face a problème a été sélectionée")
|
| 1840 |
|
|
End If
|
| 1841 |
|
|
|
| 1842 |
|
|
' 2 - Vérifier que la ligne est plane, mais ça je ne sais pas comment
|
| 1843 |
|
|
|
| 1844 |
|
|
' 3 - Perpendiculaire
|
| 1845 |
|
|
' ok, on va chercher le midpoint de la ligne et on demande la normale à cette position des 2 faces. Puis on demande(l) 'angle entre les 2 normales...
|
| 1846 |
|
|
|
| 1847 |
|
|
Dim swArete As SldWorks.Edge
|
| 1848 |
|
|
Dim vmid As Object
|
| 1849 |
|
|
Dim mid() As Double = Nothing
|
| 1850 |
|
|
Dim T As Double
|
| 1851 |
|
|
Dim u() As Double, v() As Double
|
| 1852 |
|
|
Dim angle As Double
|
| 1853 |
|
|
|
| 1854 |
|
|
If interFF.AreteCoque Is Nothing Then interFF.QuelleAreteCoqueToucheVolume()
|
| 1855 |
|
|
swArete = interFF.AreteCoque
|
| 1856 |
|
|
T = Commun.GetTMilieu(swArete)
|
| 1857 |
|
|
vmid = swArete.Evaluate(T)
|
| 1858 |
|
|
mid = vmid
|
| 1859 |
|
|
|
| 1860 |
|
|
u = sFaceVol.GetNormale(mid(0), mid(1), mid(2))
|
| 1861 |
|
|
v = sFaceCoque.GetNormale(mid(0), mid(1), mid(2))
|
| 1862 |
|
|
|
| 1863 |
|
|
angle = Outils_Math.Angle2Vecteurs(u, v)
|
| 1864 |
|
|
|
| 1865 |
|
|
If Not Math.Abs(angle - Pi / 2) < (Epsilon * 10) Then
|
| 1866 |
|
|
sFaceVol.Selectionner(, False)
|
| 1867 |
|
|
sFaceCoque.Selectionner(, True)
|
| 1868 |
|
|
Err.Raise(515, "Verifier_Coque_Section", "La face de la coque n'est pas perpendiculaire à la face représentant sa section. Les faces fautives ont été sélectionées.")
|
| 1869 |
|
|
End If
|
| 1870 |
|
|
|
| 1871 |
|
|
' 4 - vérifier que les 2 petites arètes sont coupées au milieu
|
| 1872 |
|
|
|
| 1873 |
|
|
|
| 1874 |
|
|
' maintenant on update l'attribut de la coque, par chance, j'ai les coordonnées du point milieu...
|
| 1875 |
|
|
Dim epaisseur As Double
|
| 1876 |
|
|
Dim distance1 As Double, distance2 As Double
|
| 1877 |
|
|
Dim point1(2) As Double, point2(2) As Double
|
| 1878 |
|
|
Dim p As Object = Nothing, p2 As Object = Nothing
|
| 1879 |
|
|
|
| 1880 |
|
|
If UBound(Aretes) = 3 Then
|
| 1881 |
|
|
p = Aretes(2).GetClosestPointOn(mid(0), mid(1), mid(2))
|
| 1882 |
|
|
point1(0) = p(0) : point1(1) = p(1) : point1(2) = p(2)
|
| 1883 |
|
|
distance1 = Math.Sqrt((point1(0) - mid(0)) ^ 2 + (point1(1) - mid(1)) ^ 2 + (point1(2) - mid(2)) ^ 2)
|
| 1884 |
|
|
|
| 1885 |
|
|
p = Aretes(3).GetClosestPointOn(mid(0), mid(1), mid(2))
|
| 1886 |
|
|
point2(0) = p(0) : point2(1) = p(1) : point2(2) = p(2)
|
| 1887 |
|
|
distance2 = Math.Sqrt((point2(0) - mid(0)) ^ 2 + (point2(1) - mid(1)) ^ 2 + (point2(2) - mid(2)) ^ 2)
|
| 1888 |
|
|
|
| 1889 |
|
|
If Not Math.Abs(distance1 - distance2) < Epsilon Then
|
| 1890 |
|
|
Err.Raise(516, "Verifier_Coque_Section", "La distance n'est pas la même de chaque coté de la coque")
|
| 1891 |
|
|
Else
|
| 1892 |
|
|
epaisseur = distance1 * 2
|
| 1893 |
|
|
End If
|
| 1894 |
|
|
|
| 1895 |
|
|
ElseIf UBound(Aretes) = 1 Then ' on a des cercles
|
| 1896 |
|
|
epaisseur = swModel.ClosestDistance(Aretes(0), Aretes(1), p, p2)
|
| 1897 |
|
|
If epaisseur <= 0 Then MsgBox("Il y a un problème ici...")
|
| 1898 |
|
|
Else
|
| 1899 |
|
|
MsgBox("On ne doit jamias passer ici en principe")
|
| 1900 |
|
|
End If
|
| 1901 |
|
|
|
| 1902 |
|
|
sFaceCoque.SetAttributDeCoque(epaisseur)
|
| 1903 |
|
|
|
| 1904 |
|
|
End Sub
|
| 1905 |
|
|
|
| 1906 |
|
|
''' <summary>
|
| 1907 |
|
|
''' sub qui découpe une face en fonction des paramètres qu'on lui passe.
|
| 1908 |
|
|
''' </summary>
|
| 1909 |
|
|
''' <remarks></remarks>
|
| 1910 |
|
|
Private Sub DécouperCoqueVolume()
|
| 1911 |
|
|
|
| 1912 |
|
|
Dim coque1 As SlyFaceCoque
|
| 1913 |
|
|
Dim interFF As InterCoqueVolume
|
| 1914 |
|
|
|
| 1915 |
|
|
' 1 - Pour toutes les coques
|
| 1916 |
|
|
|
| 1917 |
|
|
For Each coque1 In Commun.lst_FaceCoque
|
| 1918 |
|
|
For Each interFF In coque1.lst_InterCoqueVolume
|
| 1919 |
|
|
If interFF.FaceDeSection Then
|
| 1920 |
|
|
CoupeCoque1(interFF)
|
| 1921 |
|
|
Else
|
| 1922 |
|
|
interFF.GénérerSweep() ' étape 4
|
| 1923 |
|
|
interFF.DécouperVolume() ' étape 5
|
| 1924 |
|
|
If interFF.DoitCouperCoque Then ' on découpe aussi couper la coque selon le sweep
|
| 1925 |
|
|
interFF.DecouperCoque()
|
| 1926 |
|
|
interFF.QuelleAreteCoqueToucheVolume(True)
|
| 1927 |
|
|
Else
|
| 1928 |
|
|
interFF.QuelleAreteCoqueToucheVolume(False)
|
| 1929 |
|
|
End If
|
| 1930 |
|
|
If interFF.DerniereCoupe Then interFF.DecouperCoque()
|
| 1931 |
|
|
interFF.MarquerFacesInternes() ' étape 6
|
| 1932 |
|
|
|
| 1933 |
|
|
End If
|
| 1934 |
|
|
Next
|
| 1935 |
|
|
Next coque1
|
| 1936 |
|
|
|
| 1937 |
|
|
|
| 1938 |
|
|
End Sub
|
| 1939 |
|
|
|
| 1940 |
|
|
|
| 1941 |
|
|
|
| 1942 |
|
|
''' <summary>
|
| 1943 |
|
|
''' Lorsque la coque est modélisée en partie par un morceau de volume. Dessine et coupe.
|
| 1944 |
|
|
''' </summary>
|
| 1945 |
|
|
''' <param name="int">L'interFaceFace</param>
|
| 1946 |
|
|
''' <remarks></remarks>
|
| 1947 |
|
|
Private Sub CoupeCoque1(ByRef int As InterCoqueVolume)
|
| 1948 |
|
|
Dim sCoque As SlyFaceCoque
|
| 1949 |
|
|
Dim sVol As SlyFaceVolume
|
| 1950 |
|
|
Dim swFace As SldWorks.Face2
|
| 1951 |
|
|
Dim swent As SldWorks.Entity
|
| 1952 |
|
|
Dim sketch As SldWorks.Sketch
|
| 1953 |
|
|
Dim vEdges As Object
|
| 1954 |
|
|
Dim swArete As SldWorks.Edge
|
| 1955 |
|
|
Dim aretes() As SldWorks.Edge = Nothing
|
| 1956 |
|
|
Dim i As Integer
|
| 1957 |
|
|
|
| 1958 |
|
|
' a - prendre la face du volume
|
| 1959 |
|
|
sVol = int.sFaceVolume
|
| 1960 |
|
|
swFace = sVol.SwFace
|
| 1961 |
|
|
sVol.Selectionner(0, False)
|
| 1962 |
|
|
|
| 1963 |
|
|
' b - lui mettre une esquisse
|
| 1964 |
|
|
swModel.InsertSketch2(True)
|
| 1965 |
|
|
|
| 1966 |
|
|
' c - convertir l'esquisse déjà créée
|
| 1967 |
|
|
sketch = int.sketch
|
| 1968 |
|
|
swent = sketch
|
| 1969 |
|
|
swent.Select2(False, 0)
|
| 1970 |
|
|
|
| 1971 |
|
|
swModel.SketchUseEdge2(False)
|
| 1972 |
|
|
|
| 1973 |
|
|
' si la face est carrée
|
| 1974 |
|
|
|
| 1975 |
|
|
If swFace.GetEdgeCount = 4 Then
|
| 1976 |
|
|
' d - ajouter des lignes pour compléter l'esquisse
|
| 1977 |
|
|
Dim longueur(3) As Double
|
| 1978 |
|
|
|
| 1979 |
|
|
|
| 1980 |
|
|
Dim vLine As Object
|
| 1981 |
|
|
Dim line1 As SldWorks.SketchLine, line2 As SldWorks.SketchLine
|
| 1982 |
|
|
Dim P1 As SldWorks.SketchPoint, P2 As SldWorks.SketchPoint, P3 As SldWorks.SketchPoint, P4 As SldWorks.SketchPoint
|
| 1983 |
|
|
Dim skSeg As SldWorks.SketchSegment
|
| 1984 |
|
|
vEdges = swFace.GetEdges()
|
| 1985 |
|
|
For Each swArete In vEdges
|
| 1986 |
|
|
ReDim Preserve aretes(i)
|
| 1987 |
|
|
aretes(i) = swArete
|
| 1988 |
|
|
i += 1
|
| 1989 |
|
|
Next
|
| 1990 |
|
|
For i = 0 To 3
|
| 1991 |
|
|
longueur(i) = Commun.GetLongueurArete(vEdges(i))
|
| 1992 |
|
|
Next i
|
| 1993 |
|
|
longueur = Ordonner(longueur, aretes)
|
| 1994 |
|
|
|
| 1995 |
|
|
swent = aretes(3) : swent.Select2(False, 0) ' on prend la plus grande arète
|
| 1996 |
|
|
swModel.SketchUseEdge2(False)
|
| 1997 |
|
|
sketch = swModel.GetActiveSketch()
|
| 1998 |
|
|
vLine = sketch.GetSketchSegments()
|
| 1999 |
|
|
skSeg = vLine(0) : line1 = skSeg
|
| 2000 |
|
|
skSeg = vLine(1) : line2 = skSeg
|
| 2001 |
|
|
|
| 2002 |
|
|
P1 = line1.GetStartPoint2()
|
| 2003 |
|
|
P2 = line1.GetEndPoint2()
|
| 2004 |
|
|
P3 = line2.GetStartPoint2()
|
| 2005 |
|
|
P4 = line2.GetEndPoint2()
|
| 2006 |
|
|
|
| 2007 |
|
|
If Distance(P1.X, P1.Y, P1.Z, P3.X, P3.Y, P3.Z) < Distance(P1.X, P1.Y, P1.Z, P4.X, P4.Y, P4.Z) Then ' ligne entre 1 et 3
|
| 2008 |
|
|
swModel.CreateLine2(P1.X, P1.Y, P1.Z, P3.X, P3.Y, P3.Z)
|
| 2009 |
|
|
swModel.CreateLine2(P2.X, P2.Y, P2.Z, P4.X, P4.Y, P4.Z)
|
| 2010 |
|
|
Else ' ligne entre 1 et 4 & 2 et 3
|
| 2011 |
|
|
swModel.CreateLine2(P1.X, P1.Y, P1.Z, P4.X, P4.Y, P4.Z)
|
| 2012 |
|
|
swModel.CreateLine2(P2.X, P2.Y, P2.Z, P3.X, P3.Y, P3.Z)
|
| 2013 |
|
|
End If
|
| 2014 |
|
|
Else
|
| 2015 |
|
|
sketch = swModel.GetActiveSketch()
|
| 2016 |
|
|
End If
|
| 2017 |
|
|
swModel.InsertSketch2(True)
|
| 2018 |
|
|
|
| 2019 |
|
|
|
| 2020 |
|
|
' e - splitter
|
| 2021 |
|
|
swent = swFace : swent.Select2(False, 1)
|
| 2022 |
|
|
swent = sketch : swent.Select2(True, 4)
|
| 2023 |
|
|
swModel.InsertSplitLineProject(False, False)
|
| 2024 |
|
|
|
| 2025 |
|
|
|
| 2026 |
|
|
' f - mettre un FaceInterne sur les 2 faces résultantes.
|
| 2027 |
|
|
Dim swFeat As SldWorks.Feature
|
| 2028 |
|
|
Dim vFace As Object
|
| 2029 |
|
|
Dim swFace1 As SldWorks.Face2, swFace2 As SldWorks.Face2
|
| 2030 |
|
|
Dim attr As SldWorks.Attribute
|
| 2031 |
|
|
Dim nom As String
|
| 2032 |
|
|
Dim no As Long
|
| 2033 |
|
|
swFeat = swModel.FeatureByPositionReverse(0)
|
| 2034 |
|
|
vFace = swFeat.GetFaces
|
| 2035 |
|
|
|
| 2036 |
|
|
swFace1 = vFace(0)
|
| 2037 |
|
|
swFace2 = vFace(1)
|
| 2038 |
|
|
|
| 2039 |
|
|
swent = swFace1
|
| 2040 |
|
|
attr = swent.FindAttribute(Intersections.DefAttrFaceInterne, 0) ' si l'attribut existe déjà on pointe dessus.
|
| 2041 |
|
|
nom = "FaceInterneCoque1"
|
| 2042 |
|
|
If attr Is Nothing Then attr = Intersections.DefAttrFaceInterne.CreateInstance5(swModel, swFace1, nom, 0, 2) ' 0 = swThisconfig
|
| 2043 |
|
|
|
| 2044 |
|
|
While attr Is Nothing
|
| 2045 |
|
|
no += 1
|
| 2046 |
|
|
nom = "FaceInterneCoque" & CStr(no)
|
| 2047 |
|
|
attr = Intersections.DefAttrFaceInterne.CreateInstance5(swModel, swFace1, nom, 0, 2)
|
| 2048 |
|
|
End While
|
| 2049 |
|
|
GererDossiers("FaceInternes", nom)
|
| 2050 |
|
|
|
| 2051 |
|
|
swent = swFace2
|
| 2052 |
|
|
attr = swent.FindAttribute(Intersections.DefAttrFaceInterne, 0) ' si l'attribut existe déjà on pointe dessus.
|
| 2053 |
|
|
nom = "FaceInterneCoque1"
|
| 2054 |
|
|
If attr Is Nothing Then attr = Intersections.DefAttrFaceInterne.CreateInstance5(swModel, swFace2, nom, 0, 2) ' 0 = swThisconfig
|
| 2055 |
|
|
|
| 2056 |
|
|
While attr Is Nothing
|
| 2057 |
|
|
no += 1
|
| 2058 |
|
|
nom = "FaceInterneCoque" & CStr(no)
|
| 2059 |
|
|
attr = Intersections.DefAttrFaceInterne.CreateInstance5(swModel, swFace2, nom, 0, 2)
|
| 2060 |
|
|
End While
|
| 2061 |
|
|
GererDossiers("FaceInternes", nom)
|
| 2062 |
|
|
|
| 2063 |
|
|
|
| 2064 |
|
|
End Sub
|
| 2065 |
|
|
|
| 2066 |
|
|
|
| 2067 |
|
|
''' <summary>
|
| 2068 |
|
|
''' Détecte s'il y a une intersection entre une coque et une face d'un volume
|
| 2069 |
|
|
''' </summary>
|
| 2070 |
|
|
''' <param name="sFaceCoque"></param>
|
| 2071 |
|
|
''' <param name="sFaceVolume"></param>
|
| 2072 |
|
|
''' <param name="dessiner">Si oui, alors on dessine une ligne à l'intersection</param>
|
| 2073 |
|
|
''' <param name="sketch">Si dessiner est vrai, alors ce sketch contient la ligne d'intersection</param>
|
| 2074 |
|
|
''' <returns>Vrai s'il y a une intersection</returns>
|
| 2075 |
|
|
''' <remarks></remarks>
|
| 2076 |
|
|
Private Function DetectFaceFace(ByRef sFaceCoque As SlyFaceCoque, ByRef sFaceVolume As SlyFaceVolume, Optional ByRef dessiner As Boolean = False, Optional ByRef sketch As SldWorks.Sketch = Nothing) As Boolean
|
| 2077 |
|
|
For Each swfc As SldWorks.Face2 In sFaceCoque.lst_Faces
|
| 2078 |
|
|
For Each swFV As SldWorks.Face2 In sFaceVolume.lst_Faces
|
| 2079 |
|
|
If DetectFaceFace(swfc, swFV, dessiner, sketch) Then Return True
|
| 2080 |
|
|
Next
|
| 2081 |
|
|
Next
|
| 2082 |
|
|
End Function
|
| 2083 |
|
|
|
| 2084 |
|
|
|
| 2085 |
|
|
''' <summary>
|
| 2086 |
|
|
''' Function qui retourne vrai ou faux si 2 FACES (pas surfaces) se touchent. La routine finit par appeler la sub dessinecourbe pour dessiner la courbe.
|
| 2087 |
|
|
''' </summary>
|
| 2088 |
|
|
''' <param name="face1">Première face</param>
|
| 2089 |
|
|
''' <param name="face2">Seconde face</param>
|
| 2090 |
|
|
''' <param name="dessiner">Si l'on veut dessiner une esquisse contenant la courbe</param>
|
| 2091 |
|
|
''' <param name="Sketch">Si la première option est vrai, ce paramètre redonne l'esquisse qui contient la courbe</param>
|
| 2092 |
|
|
''' <returns>Vrai si les faces se touchent</returns>
|
| 2093 |
|
|
''' <remarks>Si les 2 faces se touchent en un seul point alors ça retourne faux.</remarks>
|
| 2094 |
|
|
Private Function DetectFaceFace(ByRef face1 As SldWorks.Face2, ByRef face2 As SldWorks.Face2, Optional ByRef dessiner As Boolean = False, Optional ByRef Sketch As SldWorks.Sketch = Nothing) As Boolean
|
| 2095 |
|
|
' sub qui détecte si 2 faces se touchent et retourne vrai si c'est le cas.
|
| 2096 |
|
|
Dim Surface1 As SldWorks.Surface
|
| 2097 |
|
|
Dim Surface2 As SldWorks.Surface
|
| 2098 |
|
|
Dim curveArray As Object = Nothing
|
| 2099 |
|
|
Dim curve As SldWorks.Curve
|
| 2100 |
|
|
Dim ret As Boolean
|
| 2101 |
|
|
Dim boundsArray As Object = Nothing
|
| 2102 |
|
|
Dim bounds() As Double
|
| 2103 |
|
|
Dim Point1(2) As Double
|
| 2104 |
|
|
Dim Point2(2) As Double
|
| 2105 |
|
|
Dim P1 As Object = Nothing, P2 As Object = Nothing
|
| 2106 |
|
|
Dim ClosestDist As Double
|
| 2107 |
|
|
|
| 2108 |
|
|
Surface1 = face1.GetSurface
|
| 2109 |
|
|
Surface2 = face2.GetSurface
|
| 2110 |
|
|
|
| 2111 |
|
|
ClosestDist = swModel.ClosestDistance(face1, face2, P1, P2)
|
| 2112 |
|
|
If ClosestDist > (Epsilon * 10) Then Return False
|
| 2113 |
|
|
|
| 2114 |
|
|
' curvearray est un tableau de curves, boundsarray est un tableau de T des limites de la courbe
|
| 2115 |
|
|
ret = Surface1.IntersectSurface(Surface2, curveArray, boundsArray) ' si c'est une ligne, retourne une ligne infinie...
|
| 2116 |
|
|
' il faut alors renvoyer vers le detectFaceArete()
|
| 2117 |
|
|
If Not ret Then Return False
|
| 2118 |
|
|
bounds = boundsArray
|
| 2119 |
|
|
|
| 2120 |
|
|
'On Error GoTo faceSurFace
|
| 2121 |
|
|
Try
|
| 2122 |
|
|
curve = curveArray(0)
|
| 2123 |
|
|
Catch
|
| 2124 |
|
|
Debug.Write("On a une intersection où 2 faces sont sur la même surface...")
|
| 2125 |
|
|
Return False ' ouch... pas certain.
|
| 2126 |
|
|
End Try
|
| 2127 |
|
|
|
| 2128 |
|
|
|
| 2129 |
|
|
If Not curve.IsLine Then ' si c'est une ligne, alors le principe de longueur ne fonctionnera pas...
|
| 2130 |
|
|
Dim longueur As Double = curve.GetLength2(bounds(0), bounds(1))
|
| 2131 |
|
|
If longueur < Epsilon Then Return False ' on a juste un point d'intersection
|
| 2132 |
|
|
Else
|
| 2133 |
|
|
Dim vParam As Object
|
| 2134 |
|
|
vParam = curve.GetClosestPointOn(P1(0), P1(1), P1(2)) ' vparam(3) est le U
|
| 2135 |
|
|
|
| 2136 |
|
|
P1 = curve.Evaluate(vParam(3) + 100 * Epsilon) : Point1 = P1
|
| 2137 |
|
|
P2 = curve.Evaluate(vParam(3) - 100 * Epsilon) : Point2 = P2
|
| 2138 |
|
|
|
| 2139 |
|
|
If (Distance(face1, Point1(0), Point1(1), Point1(2)) < Epsilon) And (Distance(face2, Point1(0), Point1(1), Point1(2)) < Epsilon) Then
|
| 2140 |
|
|
ElseIf (Distance(face1, Point2(0), Point2(1), Point2(2)) < Epsilon) And (Distance(face2, Point2(0), Point2(1), Point2(2)) < Epsilon) Then
|
| 2141 |
|
|
Else
|
| 2142 |
|
|
Return False
|
| 2143 |
|
|
End If
|
| 2144 |
|
|
End If
|
| 2145 |
|
|
|
| 2146 |
|
|
|
| 2147 |
|
|
|
| 2148 |
|
|
If dessiner Then
|
| 2149 |
|
|
Dim swent As SldWorks.Entity
|
| 2150 |
|
|
Dim feat As SldWorks.Feature
|
| 2151 |
|
|
swModel.Insert3DSketch2(False)
|
| 2152 |
|
|
|
| 2153 |
|
|
swent = face1 : swent.Select2(False, 0)
|
| 2154 |
|
|
swent = face2 : swent.Select2(True, 0)
|
| 2155 |
|
|
swModel.Sketch3DIntersections()
|
| 2156 |
|
|
|
| 2157 |
|
|
swModel.Insert3DSketch2(False)
|
| 2158 |
|
|
swModel.EditRebuild3()
|
| 2159 |
|
|
feat = swModel.FeatureByPositionReverse(0)
|
| 2160 |
|
|
|
| 2161 |
|
|
Sketch = feat.GetSpecificFeature2
|
| 2162 |
|
|
End If
|
| 2163 |
|
|
|
| 2164 |
|
|
Return True
|
| 2165 |
|
|
'If curve.IsTrimmedCurve = False And curve.IsLine Then ' si c'est une ligne, alors l'enfoirée est de longueur infinie. courbe spline... pas de problèmes.
|
| 2166 |
|
|
|
| 2167 |
|
|
' Dim vEdge As Object, swAreteTest As SldWorks.Edge, xyz() As Double = Nothing, n As Integer
|
| 2168 |
|
|
' Dim lst_T() As Double = Nothing, final() As Double
|
| 2169 |
|
|
' Dim NewCourbe As SldWorks.Curve
|
| 2170 |
|
|
|
| 2171 |
|
|
' For n = 1 To 2
|
| 2172 |
|
|
' If n = 1 Then vEdge = face1.GetEdges() Else vEdge = face2.GetEdges()
|
| 2173 |
|
|
' For f = 0 To UBound(vEdge)
|
| 2174 |
|
|
' swAreteTest = vEdge(f)
|
| 2175 |
|
|
' If DetectAreteArete(swAreteTest, curve, xyz) Then
|
| 2176 |
|
|
|
| 2177 |
|
|
' If Not UBound(xyz) > 4 Then
|
| 2178 |
|
|
' vT = curve.GetClosestPointOn(xyz(0), xyz(1), xyz(2))
|
| 2179 |
|
|
' T = vT(3)
|
| 2180 |
|
|
|
| 2181 |
|
|
' If lst_T Is Nothing Then ReDim lst_T(0) Else ReDim Preserve lst_T(UBound(lst_T) + 1)
|
| 2182 |
|
|
' lst_T(UBound(lst_T)) = T
|
| 2183 |
|
|
' End If
|
| 2184 |
|
|
' End If
|
| 2185 |
|
|
' Next f
|
| 2186 |
|
|
' Next n
|
| 2187 |
|
|
|
| 2188 |
|
|
' final = trier(lst_T)
|
| 2189 |
|
|
|
| 2190 |
|
|
' For i = 0 To UBound(final) Step 2
|
| 2191 |
|
|
' Dim skseg As SldWorks.SketchSegment, angle As Double
|
| 2192 |
|
|
|
| 2193 |
|
|
' Point1 = curve.Evaluate(final(i)) : Point2 = curve.Evaluate(final(i + 1))
|
| 2194 |
|
|
' NewCourbe = curve.CreateTrimmedCurve2(Point1(0), Point1(1), Point1(2), Point2(0), Point2(1), Point2(2))
|
| 2195 |
|
|
' If dessiner Then skseg = Commun.DessineCourbe(NewCourbe) : Sketch = skseg.GetSketch
|
| 2196 |
|
|
' angle = AngleEntre2Faces(face1, face2, Point1) / 0.0174532925
|
| 2197 |
|
|
|
| 2198 |
|
|
' 'swApp.SendMsgToUser(" Courbe Droite " & angle)
|
| 2199 |
|
|
' Next
|
| 2200 |
|
|
|
| 2201 |
|
|
'ElseIf curve.IsTrimmedCurve = False Then ' courbe périodique... donc pas trimmée mais avec des bounds...
|
| 2202 |
|
|
' If dessiner Then
|
| 2203 |
|
|
' Commun.DessineCourbe(curve)
|
| 2204 |
|
|
' Sketch = swModel.FeatureByPositionReverse(0)
|
| 2205 |
|
|
' End If
|
| 2206 |
|
|
|
| 2207 |
|
|
|
| 2208 |
|
|
'Else
|
| 2209 |
|
|
' If dessiner Then
|
| 2210 |
|
|
' Commun.DessineCourbe(curve)
|
| 2211 |
|
|
' Sketch = swModel.FeatureByPositionReverse(0)
|
| 2212 |
|
|
' End If
|
| 2213 |
|
|
'End If
|
| 2214 |
|
|
|
| 2215 |
|
|
'Return True
|
| 2216 |
|
|
faceSurFace: ' les 2 surfaces sont une sur l'autre...
|
| 2217 |
|
|
'Dim swent As SldWorks.Entity
|
| 2218 |
|
|
'Dim swent2 As SldWorks.Entity
|
| 2219 |
|
|
'swent = face1 : swent.Select2(False, 0)
|
| 2220 |
|
|
'swent2 = face2 : swent2.Select2(True, 0)
|
| 2221 |
|
|
'MsgBox("2 Faces avec une surface commune...")
|
| 2222 |
|
|
'Return True
|
| 2223 |
|
|
End Function
|
| 2224 |
|
|
|
| 2225 |
|
|
|
| 2226 |
|
|
Public Function trier(ByRef lst() As Double) As Double()
|
| 2227 |
|
|
' sub qui retourne les T min et T max en fonction de la collection.
|
| 2228 |
|
|
' normalement on enlève les 2 points max et min et il devrait nous rester un nombre pair de valeurs.
|
| 2229 |
|
|
Dim i As Integer, j As Integer
|
| 2230 |
|
|
Dim lst2() As Double
|
| 2231 |
|
|
|
| 2232 |
|
|
Dim temp As Double
|
| 2233 |
|
|
|
| 2234 |
|
|
If UBound(lst) < 1 Then Return Nothing
|
| 2235 |
|
|
|
| 2236 |
|
|
For j = 0 To UBound(lst) - 1
|
| 2237 |
|
|
For i = 0 To UBound(lst) - j - 1
|
| 2238 |
|
|
If lst(i) > lst(i + 1) Then
|
| 2239 |
|
|
temp = lst(i)
|
| 2240 |
|
|
lst(i) = lst(i + 1)
|
| 2241 |
|
|
lst(i + 1) = temp
|
| 2242 |
|
|
End If
|
| 2243 |
|
|
Next i
|
| 2244 |
|
|
Next j
|
| 2245 |
|
|
|
| 2246 |
|
|
ReDim lst2(UBound(lst) - 2)
|
| 2247 |
|
|
For i = 1 To UBound(lst) - 1
|
| 2248 |
|
|
lst2(i - 1) = lst(i)
|
| 2249 |
|
|
Next
|
| 2250 |
|
|
Return lst2
|
| 2251 |
|
|
|
| 2252 |
|
|
|
| 2253 |
|
|
|
| 2254 |
|
|
End Function
|
| 2255 |
|
|
|
| 2256 |
|
|
''' <summary>
|
| 2257 |
|
|
''' Function qui remet en ordre croissant les valeurs d'un tableau
|
| 2258 |
|
|
''' </summary>
|
| 2259 |
|
|
''' <param name="lst">Le tableau de valeurs à ordonner</param>
|
| 2260 |
|
|
''' <param name="liste2">un second tableau que l'on peut ordonner</param>
|
| 2261 |
|
|
''' <returns></returns>
|
| 2262 |
|
|
''' <remarks></remarks>
|
| 2263 |
|
|
Public Function Ordonner(ByRef lst() As Double, Optional ByRef liste2() As SldWorks.Edge = Nothing) As Double()
|
| 2264 |
|
|
|
| 2265 |
|
|
Dim i As Integer, j As Integer
|
| 2266 |
|
|
Dim temp2 As Object
|
| 2267 |
|
|
|
| 2268 |
|
|
Dim temp As Double
|
| 2269 |
|
|
|
| 2270 |
|
|
If UBound(lst) < 1 Then Return Nothing
|
| 2271 |
|
|
|
| 2272 |
|
|
For j = 0 To UBound(lst) - 1
|
| 2273 |
|
|
For i = 0 To UBound(lst) - j - 1
|
| 2274 |
|
|
If lst(i) > lst(i + 1) Then
|
| 2275 |
|
|
temp = lst(i)
|
| 2276 |
|
|
lst(i) = lst(i + 1)
|
| 2277 |
|
|
lst(i + 1) = temp
|
| 2278 |
|
|
If Not liste2 Is Nothing Then
|
| 2279 |
|
|
temp2 = liste2(i)
|
| 2280 |
|
|
liste2(i) = liste2(i + 1)
|
| 2281 |
|
|
liste2(i + 1) = temp2
|
| 2282 |
|
|
End If
|
| 2283 |
|
|
|
| 2284 |
|
|
End If
|
| 2285 |
|
|
Next i
|
| 2286 |
|
|
Next j
|
| 2287 |
|
|
|
| 2288 |
|
|
Return lst
|
| 2289 |
|
|
|
| 2290 |
|
|
|
| 2291 |
|
|
|
| 2292 |
|
|
End Function
|
| 2293 |
|
|
|
| 2294 |
|
|
|
| 2295 |
|
|
|
| 2296 |
|
|
|
| 2297 |
|
|
End Module
|