Presentation is loading. Please wait.

Presentation is loading. Please wait.

OUR PLM CONSULTANTS ARE

Similar presentations


Presentation on theme: "OUR PLM CONSULTANTS ARE"— Presentation transcript:

1

2 OUR PLM CONSULTANTS ARE
ABOUT US IT/PLM consulting services company Dassault Partner Located in Montreal (HQ) and Toulouse, France International presence (America, Asia, Europe) 50 IT and PLM consultants Strong references on 3DEXPERIENCE Projects 3 Centers of Excellence : OUR PLM CONSULTANTS ARE Bilingual Canadian/US Citizen 3DExperience strong knowledge Average of 7 years in PLM Worldwide relocation Mechanical or Computer Engineers Strong team spirit!

3 By Eric Neuville , Techso
USING WINDOWS API By Eric Neuville , Techso

4 Warnings I do not pretend to be a first class programmer.
Don’t shoot the messenger Use at your own risk

5 Climbing the Tree This code will let the user go up and down in CATIA
Spec tree using buttons in a form:

6 Climbing the Tree Create your VBA Module and copy /paste the following text into it Sub CATMain() UserForm1.Show End Sub Sub BringToFront() On Error Resume Next AppActivate CATIA.Caption On Error GoTo 0

7 Climbing the Tree Create a new Form Add 1 button change its name to
Private Sub CommandButtonUP_Click() Module1.BringToFront SendKeys "{UP}", True End Sub […] Private Sub UserForm_Initialize() CATIA.ActiveWindow.Layout = catWindowSpecsOnly Private Sub UserForm_Terminate() CATIA.ActiveWindow.Layout = catWindowSpecsAndGeom Create a new Form Add 1 button change its name to CommandButtonUP Change its caption to UP Double click the button to define its code…

8 Climbing the Tree Make 4 other buttons: DOWN LEFT RIGHT HOME
And copy paste the code from Private Sub Private Sub CommandButtonUP_Click() Module1.BringToFront SendKeys "{UP}", True End Sub and adapt to DOWN / LEFT / RIGH / HOME

9 Climbing the tree Final touch:
Make the Form1 non modal so you can do stuff in CATIA while the form is active This tree tool can be used to find the parent of a selected object as sometimes we’re dealing with occurrence and going up the tree is not that easy, also in a Part, this can help select the parent of an axis system or open/reduce geometrical set.

10 Disassemble This code will let the user run the disassemble GSD function using WINAPI as CATIA API is missing.

11 Disassemble This is the logic we want to use Start End No Yes Yes Yes
Start Disassemble Disassemble Start This is the logic we want to use End CATPart open? No Valid selection? Yes Yes Any selection? Yes No Close Disassemble No

12 Info comes from MS help WEB, or https://stackoverflow.com
The WIN API Info comes from MS help WEB, or OK, create a VBA macro And paste this code into a new module Private Declare PtrSafe Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare PtrSafe Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" (ByVal hwndParent As LongPtr, ByVal hwndChildAfter As Long, ByVal lpszClass As String, ByVal lpszWindow As String) As Long Private Declare PtrSafe Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hWnd As LongPtr, ByVal wMsg As LongPtr, ByVal wParam As LongPtr, lParam As LongPtr) As Long Private Declare PtrSafe Function SetForgroundWindow Lib "user32.dll" Alias "SetForgroundWindowA" (ByVal hWnd As LongPtr) As LongPtr Private Declare PtrSafe Function GetWindowLong Lib "user32.dll" Alias "GetWindowLongA" (ByVal hWnd As LongPtr, ByVal nIndex As LongPtr) As LongPtr

13 Info comes from MS help WEB, or https://stackoverflow.com
The WIN API Info comes from MS help WEB, or Then add also the following lines Private Const WS_DISABLED = &H Private Const BM_CLICK = &HF5 Dim hDisassemble As LongPtr Dim hOKButton As LongPtr

14 I used spyxx from MS VisualStudio to get this info
The main sub OK so first we check that CATIA is open and the selection is OK and we click OK if the button is not disabled Sub CATMain() If IsCATIAPartOpen And Not (IsSelectionEmpty) Then CATIA.StartCommand "Disassemble" While hDisassemble = 0 hDisassemble = FindWindow("#32770", "Disassemble") CATIA.RefreshDisplay = True Wend If Not (CheckOKButtonDisable) Then SendMessage hOKButton, BM_CLICK, 0, 0 End If End Sub I used spyxx from MS VisualStudio to get this info

15 The other functions Checking if a CATPart is open
Function IsCATIAPartOpen() As Boolean Dim myDoc 'As CATIADocument Set myDoc = CATIA.ActiveDocument result = False If TypeName(myDoc) = "PartDocument" Then result = True IsCATIAOpen = result End Function

16 The other functions Checking if Selection is done
Function IsSelectionEmpty() As Boolean result = False If CATIA.ActiveDocument.Selection.Count = 0 Then result = True IsSelectionEmpty = result End Function

17 The other functions Checking if the Disassemble OK button is enable
Function CheckOKButtonDisable() As Boolean While hOKButton = 0 hOKButton = FindWindowEx(hDisassemble, 0, "Button", "OK") Wend Dim myOKStyle As LongPtr myOKStyle = 0 myOKStyle = GetWindowLong(hOKButton, GWL_STYLE) result = (myOKStyle And WS_DISABLED) <> 0 CheckOKButtonDisable = result End Function

18 You’re done So you can create a sketch in your part with a rectangle in it Select the sketch once it is done and run the script See how the script react when you select something that can not be disassembled (a plane)

19 reminder The purpose of this presentation is to present tools so user who are not familiar with WIN API could start to investigate and have fun. It is recommended to manage some kind of error handling when using WIN API in order to avoid infinite loop. Please check the VB code from weagan22 on eng-tips.com for a tree reordering solution.

20 indocti discant et ament meminisse periti
QUESTIONS ? indocti discant et ament meminisse periti


Download ppt "OUR PLM CONSULTANTS ARE"

Similar presentations


Ads by Google