1 |
bournival |
48 |
Imports SolidWorks.Interop
|
2 |
|
|
Imports SolidWorks.Interop.swconst
|
3 |
|
|
Imports SolidWorks.Interop.swpublished
|
4 |
bournival |
40 |
Imports System.Runtime.InteropServices
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
Namespace MAGIC
|
8 |
|
|
<Guid("FA814A68-F365-49A2-83B1-271393167B1C")> _
|
9 |
|
|
Public Class Magic
|
10 |
|
|
Implements SWPublished.SwAddin
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
#Region "Local Variables"
|
14 |
|
|
Dim WithEvents iSwApp As SldWorks.SldWorks
|
15 |
|
|
Dim addinID As Integer
|
16 |
|
|
Dim toolbarID As Integer
|
17 |
|
|
Dim iBmp As BitmapHandler
|
18 |
|
|
Dim openDocs As New Hashtable
|
19 |
|
|
Dim ClPage As New ConditionsAuxLimites.ConditionLimitePage ' une instance de la page des propriétés pour les conditions aux limites
|
20 |
|
|
Dim RCPage As New RealConstant.RealConstant ' propriétés de real constant
|
21 |
|
|
Dim EnregistrementPage As New Enregistrement.Enregistrement ' la page des enregistrements
|
22 |
|
|
|
23 |
|
|
#End Region
|
24 |
|
|
|
25 |
|
|
#Region "SolidWorks Registration"
|
26 |
|
|
|
27 |
|
|
<ComRegisterFunction()> Public Shared Sub RegisterFunction(ByVal t As Type)
|
28 |
|
|
Dim hklm As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.LocalMachine
|
29 |
|
|
Dim hkcu As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.CurrentUser
|
30 |
|
|
|
31 |
|
|
Dim keyname As String = "SOFTWARE\SolidWorks\Addins\{" + t.GUID.ToString() + "}"
|
32 |
|
|
Dim addinkey As Microsoft.Win32.RegistryKey = hklm.CreateSubKey(keyname)
|
33 |
|
|
addinkey.SetValue(Nothing, 0)
|
34 |
|
|
addinkey.SetValue("Description", "Fonctions nécessaires pour faire le lien avec MAGIC")
|
35 |
|
|
addinkey.SetValue("Sylvain", "MAGIC")
|
36 |
|
|
|
37 |
|
|
keyname = "Software\SolidWorks\AddInsStartup\{" + t.GUID.ToString() + "}"
|
38 |
|
|
addinkey = hkcu.CreateSubKey(keyname)
|
39 |
|
|
addinkey.SetValue(Nothing, 0)
|
40 |
|
|
End Sub
|
41 |
|
|
|
42 |
|
|
<ComUnregisterFunction()> Public Shared Sub UnregisterFunction(ByVal t As Type)
|
43 |
|
|
Dim hklm As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.LocalMachine
|
44 |
|
|
Dim hkcu As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.CurrentUser
|
45 |
|
|
|
46 |
|
|
Dim keyname As String = "SOFTWARE\SolidWorks\Addins\{" + t.GUID.ToString() + "}"
|
47 |
|
|
hklm.DeleteSubKey(keyname)
|
48 |
|
|
|
49 |
|
|
keyname = "Software\SolidWorks\AddInsStartup\{" + t.GUID.ToString() + "}"
|
50 |
|
|
hkcu.DeleteSubKey(keyname)
|
51 |
|
|
End Sub
|
52 |
|
|
|
53 |
|
|
#End Region
|
54 |
|
|
|
55 |
|
|
#Region "ISwAddin Implementation"
|
56 |
|
|
' la fonction qui est callée quand on clique sur OK dans le outil- complément
|
57 |
|
|
Function ConnectToSW(ByVal ThisSW As Object, ByVal Cookie As Integer) As Boolean Implements SWPublished.SwAddin.ConnectToSW
|
58 |
|
|
iSwApp = ThisSW
|
59 |
|
|
addinID = Cookie
|
60 |
|
|
iBmp = New BitmapHandler
|
61 |
|
|
|
62 |
|
|
iSwApp.SetAddinCallbackInfo(0, Me, addinID)
|
63 |
|
|
|
64 |
|
|
swApp = iSwApp ' quelques objets settés dans les modules....
|
65 |
|
|
Commun.swModel = iSwApp.ActiveDoc
|
66 |
|
|
Commun.swPart = Commun.swModel
|
67 |
|
|
|
68 |
|
|
AddMenus()
|
69 |
|
|
AddToolbar()
|
70 |
|
|
AttachEventHandlers()
|
71 |
|
|
AddPMP()
|
72 |
|
|
ConnectToSW = True
|
73 |
|
|
End Function
|
74 |
|
|
|
75 |
|
|
Function DisconnectFromSW() As Boolean Implements SWPublished.SwAddin.DisconnectFromSW
|
76 |
|
|
RemoveMenus()
|
77 |
|
|
RemoveToolbar()
|
78 |
|
|
DetachEventHandlers()
|
79 |
|
|
RemovePMP()
|
80 |
|
|
|
81 |
|
|
iBmp.Dispose()
|
82 |
|
|
iSwApp = Nothing
|
83 |
|
|
|
84 |
|
|
'The addin _must_ call GC.Collect() here in order to retrieve all managed code pointers
|
85 |
|
|
GC.Collect()
|
86 |
|
|
DisconnectFromSW = True
|
87 |
|
|
End Function
|
88 |
|
|
#End Region
|
89 |
|
|
|
90 |
|
|
#Region "Les Menus"
|
91 |
|
|
Sub AddMenus()
|
92 |
|
|
' on ajoute des menus pour la barre en haut...
|
93 |
|
|
Dim docType As Integer
|
94 |
|
|
Dim pos As Integer
|
95 |
|
|
|
96 |
|
|
pos = 3
|
97 |
|
|
'docType = swDocumentTypes_e.swDocNONE
|
98 |
|
|
'iSwApp.AddMenu(docType, "MAGIC", pos)
|
99 |
|
|
'iSwApp.AddMenuItem2(docType, addinID, "Condition Limite@MAGIC", -1, "Condition Limite", "PMPEnable", "Montre la page de propriété des conditions aux limites")
|
100 |
|
|
'iSwApp.AddMenuItem2(docType, addinID, "PropPoutreCoque@MAGIC", -1, "Condition Limite", "PMPEnable", "Montre la page de propriété des poutres et des coques")
|
101 |
|
|
|
102 |
|
|
pos = 6
|
103 |
|
|
If Not iSwApp.ActiveDoc Is Nothing Then
|
104 |
|
|
If Not iSwApp.ActiveDoc.GetFirstModelView().FrameState = swWindowState_e.swWindowMaximized Then
|
105 |
|
|
pos = 5
|
106 |
|
|
End If
|
107 |
|
|
End If
|
108 |
|
|
|
109 |
|
|
'SldWorks.AddMenuItem2 ( DocumentType, Cookie, MenuItem, Position, MenuCallback, MenuEnableMethod, HintString )
|
110 |
|
|
' MenuItem: Menu string ("menuItem@subMenuString@menuString");
|
111 |
|
|
' position, si -1 alors créé à la fin de la liste
|
112 |
|
|
' MenuCallBack, fonction qui est appelée quand on clique sur le truc
|
113 |
|
|
' Menu enabled, une parmis les options si on veut voir le menu enabled ou sélectionné
|
114 |
|
|
docType = swDocumentTypes_e.swDocPART
|
115 |
|
|
iSwApp.AddMenu(docType, "MAGIC", pos)
|
116 |
|
|
iSwApp.AddMenuItem2(docType, addinID, "Condition Limite@MAGIC", -1, "ShowCL", "PMPEnable", "Montre la page pour ajouter des conditions aux limites")
|
117 |
|
|
iSwApp.AddMenuItem2(docType, addinID, "Exporter vers MAGiC@MAGIC", -1, "EnregistrerMagic", "PMPEnable", "Exporter le fichier sous le nom actuel et le prépare pour qu'il puisse être relu correctement par MAGIC")
|
118 |
|
|
iSwApp.AddMenuItem2(docType, addinID, "Propriete poutres et coques@MAGIC", -1, "ShowRC", "PMPEnable", "Montre la page de propriété des poutres et des coques")
|
119 |
|
|
iSwApp.AddMenuItem2(docType, addinID, "LectureAttribut@MAGIC", -1, "LireRC", "PMPEnable", "Montre la page des attributs sélectionnés")
|
120 |
|
|
iSwApp.AddMenuItem2(docType, addinID, "Test@MAGIC", -1, "Test", "PMPEnable", "Un icone pour faire des tests...")
|
121 |
|
|
|
122 |
|
|
' affichage des menus pour les assemblages
|
123 |
|
|
' docType = swDocumentTypes_e.swDocASSEMBLY
|
124 |
|
|
' iSwApp.AddMenu(docType, "MAGIC", pos)
|
125 |
|
|
' iSwApp.AddMenuItem2(docType, addinID, "Show PMP@MAGIC", -1, "ShowPMP", "PMPEnable", "Displays the Property ManagerPage")
|
126 |
|
|
|
127 |
|
|
' affichage de smenus pour les dessins (drawing documents)
|
128 |
|
|
' docType = swDocumentTypes_e.swDocDRAWING
|
129 |
|
|
' iSwApp.AddMenu(docType, "MAGIC", pos)
|
130 |
|
|
' iSwApp.AddMenuItem2(docType, addinID, "Show PMP@MAGIC", -1, "ShowPMP", "PMPEnable", "Displays the Property ManagerPage")
|
131 |
|
|
End Sub
|
132 |
|
|
|
133 |
|
|
Sub RemoveMenus()
|
134 |
|
|
Dim docType As Integer
|
135 |
|
|
|
136 |
|
|
docType = swDocumentTypes_e.swDocNONE
|
137 |
|
|
iSwApp.RemoveMenu(docType, "MAGIC", "")
|
138 |
|
|
|
139 |
|
|
docType = swDocumentTypes_e.swDocPART
|
140 |
|
|
iSwApp.RemoveMenu(docType, "MAGIC", "")
|
141 |
|
|
|
142 |
|
|
docType = swDocumentTypes_e.swDocASSEMBLY
|
143 |
|
|
iSwApp.RemoveMenu(docType, "MAGIC", "")
|
144 |
|
|
|
145 |
|
|
docType = swDocumentTypes_e.swDocDRAWING
|
146 |
|
|
iSwApp.RemoveMenu(docType, "MAGIC", "")
|
147 |
|
|
End Sub
|
148 |
|
|
|
149 |
|
|
Sub AddToolbar()
|
150 |
|
|
' c'est ici que l'on ajoute des boutons dans la nouvelle toolbar
|
151 |
|
|
Dim smallImagePath As String
|
152 |
|
|
Dim largeImagePath As String
|
153 |
|
|
Dim docType As Integer
|
154 |
|
|
|
155 |
|
|
smallImagePath = iBmp.CreateFileFromResourceBitmap("MAGIC.ToolbarSmall.bmp")
|
156 |
|
|
largeImagePath = iBmp.CreateFileFromResourceBitmap("MAGIC.ToolbarLarge.bmp")
|
157 |
|
|
|
158 |
|
|
docType = swDocTemplateTypes_e.swDocTemplateTypePART Or _
|
159 |
|
|
swDocTemplateTypes_e.swDocTemplateTypeASSEMBLY Or _
|
160 |
|
|
swDocTemplateTypes_e.swDocTemplateTypeDRAWING Or _
|
161 |
|
|
swDocTemplateTypes_e.swDocTemplateTypeNONE
|
162 |
|
|
' AddToolbarCommand2 ( Cookie, ToolbarID, ToolbarIndex, ButtonCallback, ButtonEnableMethod, ToolTip, HintString )
|
163 |
|
|
' ButtonCallback = fonction appelée quand on clique sur le bouton
|
164 |
|
|
' ButtonEnableMethod = fonction à appeler pour savoir si le bouton doit être enabled
|
165 |
|
|
' HintString = ce qui apparait dans la statucbar quand la souris est par-dessus l'icone
|
166 |
|
|
toolbarID = iSwApp.AddToolbar4(addinID, "MAGIC", smallImagePath, largeImagePath, 0, docType)
|
167 |
|
|
iSwApp.AddToolbarCommand2(addinID, toolbarID, 0, "ShowCL", "ToolbarEnable0", "Condition aux limites", "Ajouter une condition aux limites en fonction des entités sélectionnées")
|
168 |
|
|
iSwApp.AddToolbarCommand2(addinID, toolbarID, 1, "EnregistrerMagic", "ToolbarEnable1", "Enregistrer pour MAGIC", "Enregistre le fichier sous le nom actuel et le prépare pour qu'il puisse être relu correctement par MAGIC")
|
169 |
|
|
iSwApp.AddToolbarCommand2(addinID, toolbarID, 2, "ShowRC", "ToolbarEnable2", "Propriétés des poutres et coques", "Pour ajouter les constantes nécessaires aux poutres et aux coques")
|
170 |
|
|
iSwApp.AddToolbarCommand2(addinID, toolbarID, 3, "LireRC", "ToolbarEnable3", "Lire un attribut", "Pour voir les propriétés des attributs")
|
171 |
|
|
iSwApp.AddToolbarCommand2(addinID, toolbarID, 4, "Intersection", "ToolbarEnable4", "Intersections", "Pour gérer les intersections")
|
172 |
|
|
iSwApp.AddToolbarCommand2(addinID, toolbarID, 5, "Test", "ToolbarEnable6", "Test", "Pour gérer les intersections")
|
173 |
|
|
|
174 |
|
|
iSwApp.AddToolbarCommand2(addinID, toolbarID, 6, "Fonction1", "ToolbarEnable7", "Fonction supplémentaire 1", "Fonction supplémentaire 1")
|
175 |
|
|
iSwApp.AddToolbarCommand2(addinID, toolbarID, 7, "Fonction2", "ToolbarEnable8", "Fonction supplémentaire 1", "Fonction supplémentaire 1")
|
176 |
|
|
iSwApp.AddToolbarCommand2(addinID, toolbarID, 8, "Fonction3", "ToolbarEnable9", "Fonction supplémentaire 1", "Fonction supplémentaire 1")
|
177 |
|
|
iSwApp.AddToolbarCommand2(addinID, toolbarID, 9, "fonction4", "ToolbarEnable10", "Fonction supplémentaire 1", "Fonction supplémentaire 1")
|
178 |
|
|
|
179 |
|
|
|
180 |
|
|
End Sub
|
181 |
|
|
|
182 |
|
|
Sub RemoveToolbar()
|
183 |
|
|
iSwApp.RemoveToolbar2(addinID, toolbarID)
|
184 |
|
|
End Sub
|
185 |
|
|
|
186 |
|
|
Function AddPMP() As Boolean
|
187 |
|
|
ClPage = New ConditionsAuxLimites.ConditionLimitePage
|
188 |
|
|
ClPage.Init(iSwApp, Me)
|
189 |
|
|
|
190 |
|
|
RCPage = New RealConstant.RealConstant
|
191 |
|
|
RCPage.Init(iSwApp, Me)
|
192 |
|
|
|
193 |
|
|
EnregistrementPage = New Enregistrement.Enregistrement
|
194 |
|
|
EnregistrementPage.Init(iSwApp, Me)
|
195 |
|
|
|
196 |
|
|
End Function
|
197 |
|
|
|
198 |
|
|
Function RemovePMP() As Boolean
|
199 |
|
|
ClPage = Nothing
|
200 |
|
|
RCPage = Nothing
|
201 |
|
|
End Function
|
202 |
|
|
#End Region
|
203 |
|
|
|
204 |
|
|
#Region "Event Subroutines"
|
205 |
|
|
Sub AttachEventHandlers()
|
206 |
|
|
AttachSWEvents()
|
207 |
|
|
|
208 |
|
|
'Listen for events on all currently open docs
|
209 |
bournival |
48 |
Dim modDoc As sldworks.ModelDoc2
|
210 |
bournival |
40 |
modDoc = iSwApp.GetFirstDocument()
|
211 |
|
|
While (Not modDoc Is Nothing)
|
212 |
|
|
If (Not openDocs.Contains(modDoc)) Then
|
213 |
|
|
AttachModelDocEventHandler(modDoc)
|
214 |
|
|
End If
|
215 |
|
|
modDoc = modDoc.GetNext
|
216 |
|
|
End While
|
217 |
|
|
End Sub
|
218 |
|
|
|
219 |
|
|
Sub DetachEventHandlers()
|
220 |
|
|
DetachSWEvents()
|
221 |
|
|
|
222 |
|
|
'Close events on all currently open docs
|
223 |
|
|
Dim docHandler As DocumentEventHandler
|
224 |
bournival |
48 |
Dim key As sldworks.ModelDoc2
|
225 |
bournival |
40 |
Dim numKeys As Integer
|
226 |
|
|
numKeys = openDocs.Count
|
227 |
|
|
If numKeys > 0 Then
|
228 |
|
|
Dim keys() As Object = New Object() {numKeys}
|
229 |
|
|
|
230 |
|
|
'Remove all document event handlers
|
231 |
|
|
openDocs.Keys.CopyTo(keys, 0)
|
232 |
|
|
For Each key In keys
|
233 |
|
|
docHandler = openDocs.Item(key)
|
234 |
|
|
docHandler.DetachEventHandlers() 'This also removes the pair from the hash
|
235 |
|
|
docHandler = Nothing
|
236 |
|
|
key = Nothing
|
237 |
|
|
Next
|
238 |
|
|
End If
|
239 |
|
|
End Sub
|
240 |
|
|
|
241 |
|
|
Function AttachSWEvents()
|
242 |
|
|
AddHandler iSwApp.ActiveDocChangeNotify, AddressOf Me.SldWorks_ActiveDocChangeNotify
|
243 |
|
|
AddHandler iSwApp.DocumentLoadNotify, AddressOf Me.SldWorks_DocumentLoadNotify
|
244 |
|
|
AddHandler iSwApp.FileNewNotify2, AddressOf Me.SldWorks_FileNewNotify2
|
245 |
|
|
AddHandler iSwApp.ActiveModelDocChangeNotify, AddressOf Me.SldWorks_ActiveModelDocChangeNotify
|
246 |
|
|
End Function
|
247 |
|
|
|
248 |
|
|
Function DetachSWEvents()
|
249 |
|
|
RemoveHandler iSwApp.ActiveDocChangeNotify, AddressOf Me.SldWorks_ActiveDocChangeNotify
|
250 |
|
|
RemoveHandler iSwApp.DocumentLoadNotify, AddressOf Me.SldWorks_DocumentLoadNotify
|
251 |
|
|
RemoveHandler iSwApp.FileNewNotify2, AddressOf Me.SldWorks_FileNewNotify2
|
252 |
|
|
RemoveHandler iSwApp.ActiveModelDocChangeNotify, AddressOf Me.SldWorks_ActiveModelDocChangeNotify
|
253 |
|
|
End Function
|
254 |
|
|
|
255 |
bournival |
48 |
Function AttachModelDocEventHandler(ByVal modDoc As sldworks.ModelDoc2) As Boolean
|
256 |
bournival |
40 |
If modDoc Is Nothing Then
|
257 |
|
|
Return False
|
258 |
|
|
End If
|
259 |
|
|
Dim docHandler As DocumentEventHandler
|
260 |
|
|
|
261 |
|
|
If Not openDocs.Contains(modDoc) Then
|
262 |
|
|
Select Case modDoc.GetType
|
263 |
|
|
Case swDocumentTypes_e.swDocPART
|
264 |
|
|
docHandler = New PartEventHandler
|
265 |
|
|
End Select
|
266 |
|
|
|
267 |
|
|
docHandler.Init(iSwApp, Me, modDoc)
|
268 |
|
|
docHandler.AttachEventHandlers()
|
269 |
|
|
openDocs.Add(modDoc, docHandler)
|
270 |
|
|
End If
|
271 |
|
|
End Function
|
272 |
|
|
|
273 |
bournival |
48 |
Function DetachModelEventHandler(ByVal modDoc As sldworks.ModelDoc2)
|
274 |
bournival |
40 |
Dim docHandler As DocumentEventHandler
|
275 |
|
|
docHandler = openDocs.Item(modDoc)
|
276 |
|
|
openDocs.Remove(modDoc)
|
277 |
|
|
modDoc = Nothing
|
278 |
|
|
docHandler = Nothing
|
279 |
|
|
End Function
|
280 |
|
|
#End Region
|
281 |
|
|
|
282 |
|
|
#Region "Event Callbacks"
|
283 |
|
|
Function SldWorks_ActiveDocChangeNotify() As Integer
|
284 |
|
|
'TODO: Add your implementation here
|
285 |
|
|
End Function
|
286 |
|
|
|
287 |
|
|
Function SldWorks_DocumentLoadNotify(ByVal docTitle As String, ByVal docPath As String) As Integer
|
288 |
bournival |
48 |
Dim modDoc As sldworks.ModelDoc2
|
289 |
bournival |
40 |
modDoc = iSwApp.GetFirstDocument()
|
290 |
|
|
While Not modDoc Is Nothing
|
291 |
|
|
If modDoc.GetTitle = docTitle Then
|
292 |
|
|
If Not openDocs.Contains(modDoc) Then
|
293 |
|
|
AttachModelDocEventHandler(modDoc)
|
294 |
|
|
End If
|
295 |
|
|
End If
|
296 |
|
|
modDoc = modDoc.GetNext()
|
297 |
|
|
End While
|
298 |
|
|
End Function
|
299 |
|
|
|
300 |
|
|
Function SldWorks_FileNewNotify2(ByVal newDoc As Object, ByVal doctype As Integer, ByVal templateName As String) As Integer
|
301 |
|
|
'TODO: Add your implementation here
|
302 |
|
|
End Function
|
303 |
|
|
|
304 |
|
|
Function SldWorks_ActiveModelDocChangeNotify() As Integer
|
305 |
|
|
'TODO: Add your implementation here
|
306 |
|
|
End Function
|
307 |
|
|
#End Region
|
308 |
|
|
|
309 |
|
|
#Region "Événements déclencheurs"
|
310 |
|
|
Sub MenuCallback()
|
311 |
|
|
|
312 |
|
|
|
313 |
|
|
' on mettra du code plus tard si ça nous intéresse...
|
314 |
|
|
MsgBox("Sub MenuCallback, Rien pour l'instant")
|
315 |
|
|
|
316 |
|
|
End Sub
|
317 |
|
|
|
318 |
|
|
Function MenuEnable() As Integer
|
319 |
|
|
MenuEnable = 1
|
320 |
|
|
End Function
|
321 |
|
|
|
322 |
|
|
Sub EnregistrerMagic()
|
323 |
|
|
videliste()
|
324 |
|
|
Commun.swModel = iSwApp.ActiveDoc
|
325 |
|
|
Commun.swPart = Commun.swModel
|
326 |
|
|
Debug.Assert(Not swPart Is Nothing, "EnregistrerMagic, le part a pas pris son pointeur")
|
327 |
|
|
'Commun.ColorerAretes() ' pas très utile, mais force le rebuild du modèle ce qui remet les attributs à jour. AVANT de lancer la fenètre enregistrement page.
|
328 |
|
|
If Not (Right(swModel.GetPathName(), 12) = "MAGiC.Sldprt") Then EnregistrementPage.Show() Else MsgBox("Impossible d'exporter un modèle déjà modifié." & vbCr & vbCr & "Essayez d'exporter le modèle original, celui-ci est déjà un modèle d'exportation!", MsgBoxStyle.Critical, )
|
329 |
|
|
|
330 |
|
|
End Sub
|
331 |
|
|
|
332 |
|
|
Sub ShowCL()
|
333 |
|
|
Commun.swModel = iSwApp.ActiveDoc
|
334 |
|
|
Commun.swPart = Commun.swModel
|
335 |
|
|
Debug.Assert(Not swPart Is Nothing, "ShowCL, le part a pas pris son pointeur")
|
336 |
|
|
ClPage.Show()
|
337 |
|
|
End Sub
|
338 |
|
|
|
339 |
|
|
Sub ShowRC()
|
340 |
|
|
Commun.swModel = iSwApp.ActiveDoc
|
341 |
|
|
Commun.swPart = Commun.swModel
|
342 |
|
|
Debug.Assert(Not swPart Is Nothing, "ShowRC, le part a pas pris son pointeur")
|
343 |
|
|
RCPage.Show()
|
344 |
|
|
End Sub
|
345 |
|
|
|
346 |
|
|
Sub LireRC()
|
347 |
|
|
Commun.swModel = iSwApp.ActiveDoc
|
348 |
|
|
Commun.swPart = Commun.swModel
|
349 |
|
|
Debug.Assert(Not swPart Is Nothing, "LireRC, le part a pas pris son pointeur")
|
350 |
|
|
|
351 |
|
|
RealConstant.RCCode.LectureRC()
|
352 |
|
|
Commun.ColorerAretes() ' ouais, un bouton et 2 fonctions... mais c'est du débuggage.
|
353 |
|
|
End Sub
|
354 |
|
|
|
355 |
|
|
Sub Intersection()
|
356 |
|
|
MsgBox("Le code qui est ici ne devrait pas être ici. Si ce msgbox apparait, trouver son appeleur, et corriger ...")
|
357 |
|
|
'Dim attr As SldWorks.Attribute
|
358 |
|
|
'Dim selmgr As SldWorks.SelectionMgr = swModel.SelectionManager
|
359 |
|
|
'Dim swent As SldWorks.Entity
|
360 |
|
|
'Dim feat As SldWorks.Feature
|
361 |
|
|
'Dim p As SldWorks.Parameter
|
362 |
|
|
|
363 |
|
|
|
364 |
|
|
'Try
|
365 |
|
|
' attr = selmgr.GetSelectedObject5(1) ' le feature est l'attribut directement
|
366 |
|
|
' p = attr.GetParameter("Maitre")
|
367 |
|
|
' swent = attr.GetEntity2()
|
368 |
|
|
' swent.Select4(False, Nothing)
|
369 |
|
|
' MsgBox("Premier, le maitre est: " & p.GetStringValue)
|
370 |
|
|
|
371 |
|
|
'Catch ex As Exception
|
372 |
|
|
' Try
|
373 |
|
|
' feat = selmgr.GetSelectedObject5(1)
|
374 |
|
|
' attr = feat.GetSpecificFeature2()
|
375 |
|
|
' swent = attr.GetEntity2()
|
376 |
|
|
' swent.Select4(False, Nothing)
|
377 |
|
|
' p = attr.GetParameter("Maitre")
|
378 |
|
|
' MsgBox("Second, le maitre est: " & p.GetStringValue)
|
379 |
|
|
|
380 |
|
|
' Catch ex2 As Exception
|
381 |
|
|
' MsgBox("Rien a marché")
|
382 |
|
|
' End Try
|
383 |
|
|
|
384 |
|
|
'End Try
|
385 |
|
|
|
386 |
|
|
|
387 |
|
|
End Sub
|
388 |
|
|
|
389 |
|
|
|
390 |
|
|
|
391 |
|
|
Sub Test()
|
392 |
|
|
Commun.swModel = iSwApp.ActiveDoc
|
393 |
|
|
Commun.swPart = Commun.swModel
|
394 |
|
|
Debug.Assert(Not swPart Is Nothing, "Test, le part a pas pris son pointeur")
|
395 |
|
|
PoGCode.test()
|
396 |
|
|
End Sub
|
397 |
|
|
|
398 |
|
|
|
399 |
|
|
|
400 |
|
|
Sub Fonction1()
|
401 |
|
|
Commun.swModel = iSwApp.ActiveDoc
|
402 |
|
|
Commun.swPart = Commun.swModel
|
403 |
|
|
Debug.Assert(Not swPart Is Nothing, "Fonction1, le part a pas pris son pointeur")
|
404 |
|
|
|
405 |
|
|
' faire quelquechose
|
406 |
|
|
'MsgBox("Le bouton de la fonction #1 a été appuyé, mais il n'y a pas encore de code dessous" & vbCr & "Spottez ce Msgbox et placer du code en dessous pour appeler la sous-routine qui démarre votre programme.", MsgBoxStyle.Exclamation)
|
407 |
|
|
Enregistrement.EnregistrementCode.dessinerCL()
|
408 |
|
|
|
409 |
|
|
End Sub
|
410 |
|
|
|
411 |
|
|
Sub Fonction2()
|
412 |
|
|
Commun.swModel = iSwApp.ActiveDoc
|
413 |
|
|
Commun.swPart = Commun.swModel
|
414 |
|
|
Debug.Assert(Not swPart Is Nothing, "Fonction2, le part a pas pris son pointeur")
|
415 |
|
|
|
416 |
bournival |
130 |
Commun.DessinerSensAretesEtNormaleFace()
|
417 |
|
|
'MsgBox("Le bouton de la fonction #2 a été appuyé, mais il n'y a pas encore de code dessous" & vbCr & "Spottez ce Msgbox et placer du code en dessous pour appeler la sous-routine qui démarre votre programme.", MsgBoxStyle.Exclamation)
|
418 |
bournival |
40 |
' faire quelquechose
|
419 |
|
|
|
420 |
|
|
End Sub
|
421 |
|
|
|
422 |
|
|
Sub Fonction3()
|
423 |
|
|
Commun.swModel = iSwApp.ActiveDoc
|
424 |
|
|
Commun.swPart = Commun.swModel
|
425 |
|
|
Debug.Assert(Not swPart Is Nothing, "Fonction3, le part a pas pris son pointeur")
|
426 |
|
|
|
427 |
|
|
' faire quelquechose
|
428 |
bournival |
130 |
Dim form As New Debug_form
|
429 |
|
|
Dim liste() As String : ReDim liste(0)
|
430 |
|
|
Dim i As Integer = 0
|
431 |
|
|
For Each f As SlyFaceVolume In Commun.lst_FaceVolume
|
432 |
|
|
ReDim Preserve liste(i)
|
433 |
|
|
liste(i) = f.nom
|
434 |
|
|
i += 1
|
435 |
|
|
Next
|
436 |
|
|
form.ListBox2.DataSource = liste
|
437 |
|
|
form.Show()
|
438 |
bournival |
40 |
End Sub
|
439 |
|
|
|
440 |
|
|
Sub Fonction4()
|
441 |
|
|
Commun.swModel = iSwApp.ActiveDoc
|
442 |
|
|
Commun.swPart = Commun.swModel
|
443 |
|
|
Debug.Assert(Not swPart Is Nothing, "Fonction4, le part a pas pris son pointeur")
|
444 |
|
|
|
445 |
|
|
' faire quelquechose
|
446 |
|
|
'MsgBox("Le bouton de la fonction #4 a été appuyé, mais il n'y a pas encore de code dessous" & vbCr & "Spottez ce Msgbox et placer du code en dessous pour appeler la sous-routine qui démarre votre programme.", MsgBoxStyle.Exclamation)
|
447 |
|
|
|
448 |
|
|
Commun.test()
|
449 |
|
|
|
450 |
|
|
End Sub
|
451 |
|
|
|
452 |
|
|
|
453 |
|
|
Function PMPEnable() As Integer
|
454 |
|
|
If iSwApp.ActiveDoc = Nothing Then
|
455 |
|
|
PMPEnable = 0
|
456 |
|
|
Else
|
457 |
|
|
PMPEnable = 1
|
458 |
|
|
End If
|
459 |
|
|
End Function
|
460 |
|
|
|
461 |
|
|
|
462 |
|
|
|
463 |
|
|
|
464 |
|
|
|
465 |
|
|
|
466 |
|
|
'Toolbar Callbacks
|
467 |
|
|
Sub ToolbarCallback0()
|
468 |
|
|
|
469 |
|
|
End Sub
|
470 |
|
|
|
471 |
|
|
Function ToolbarEnable0() As Integer
|
472 |
|
|
Return 1
|
473 |
|
|
End Function
|
474 |
|
|
|
475 |
|
|
|
476 |
|
|
Function ToolbarEnable1() As Integer
|
477 |
|
|
Return 1
|
478 |
|
|
End Function
|
479 |
|
|
|
480 |
|
|
Sub ToolbarCallback2()
|
481 |
|
|
|
482 |
|
|
End Sub
|
483 |
|
|
|
484 |
|
|
Function ToolbarEnable2() As Integer
|
485 |
|
|
Return 1
|
486 |
|
|
End Function
|
487 |
|
|
#End Region
|
488 |
|
|
|
489 |
|
|
|
490 |
|
|
|
491 |
|
|
|
492 |
|
|
|
493 |
|
|
End Class
|
494 |
|
|
|
495 |
|
|
End Namespace |