Int. Journal of Applied Sciences and Engineering Research, Vol. 4, Issue 4, 2015 © 2015 by the authors – Licensee IJASER- Under Creative Commons License 3.0 Research article www.ijaser.com editorial@ijaser.com ISSN 2277 – 9442 Practical aspects for development of add-in solid works applications on example of optimization problems Mikhail V. Chugunov 1, Akexander V. Schekin 2 1- Asst. Professor, Department of Mechanical Engineering Ogarev Mordovia State University, Russia 2- Engineer, Department of Mechanical Engineering Ogarev Mordovia State University, Russia DOI: 10.6088.ijaser.04050 Abstract: This paper proposes some practical approaches that are intended to provide Add-In SolidWorks applications development. Problem includes two parts: design tree analysis for an existing model, including design history and parametric information; modification of the SolidWorks model. The both parts are integrated in one system, based on SolidWorks API, COM-interface and special user interface, built into SolidWorks windows. Keywords: Add-In SolidWorks Application, Parametric Model, Meta-model, User Interface, COM-Interface, API, Optimization Problem 1. Introduction Add-In Application has a purpose to improve and to extend a basic functionality of modern software. CAD/CAE-systems are knowledge-intensive, high-technology software that has powerful API. It is best opportunity to focus on creativity (“Do not reinvent a wheel”), using well-known CAD/CAE-systems as the template. SolidWorks is one of the powerful CAD/CAE-software (from our point of view). So, those problems that are not included into the basic SolidWorks functionality are looking as the most interesting (Jun Wang, 2011). We offer one problem for example used in this context. An optimization problem for which objective and constraint functions are approximated, using step by step method with mid-range approximations (Toropov V.V. and Polynkin A.A., 1992, 2012) and is considered. This optimization functions are represented as analytical expressions, formulated by the least-squares method for small sub-regions of the design space (metamodel functions). The FEM-experiments (or another “accurate” but computationally expansive method) are carried out at some points at the design sub-region for the parameters of the analytical expressions determining. Then the partial optimization problem is solving within the sub-region, using simplified objective and constraints metamodel functions. The choice of the next search sub-region is dependent on previously obtained optimal results for the sub-region. So, the optimization procedure is sequential solving of the partial less computationally expensive problems, moving the sub-regions toward optimum. Another approach is the fully-stressed design (FSD), it is often not optimal (Rozvany G. I. N., 2009), but at the same time, it is a popular alternative method to perform structural redesign that does not use the expensive optimization algorithms. A fully stressed state is reached when all its substructures (or small elements, FEs, for example) are utilized to their full strength capacity. In any case it is necessary to solve some common problems, concerning Add-In software development aspects. ————————————— *Corresponding author (e-mail: m.v.chugunov@mail.ru) Received on April 2014; Published on August, 2015 494 Practical aspects for development of Add-In SolidWorks applications on example of optimization problems 2. SolidWorks design tree analysis and modification of the model The analysis of the SolidWorks design tree is carried out in the enclosed cycles as it are depicted in Figure 1. As a result, all information of the model is provided in some intermediate format, and it is ready for further using regarding for definition of the optimizing problem, and regarding for solving of the optimization task. Figure 1: Solid Works construction tree analysis In Figure 1 also some fragments of the C++ code (MS Visual Studio C++ and COM) for extraction of the model data are depicted. So, in particular, shell and equation managers, GetSpecificFeature2 and QueryInterface functions are used for extraction of the following parameters: dimensions, equations, and also thicknesses and physic-mechanical properties of the shells. Mikhail V. Chugunov1, Akexander V. Schekin Int. Journal of Applied Sciences and Engineering Research, Vol. 4, No. 4, 2015 495 Practical aspects for development of Add-In SolidWorks applications on example of optimization problems As the algorithm of discretely full-stressed design is applied, as a rule, to thin-walled parts, all shells are being selected from design tree and tension sensors are being placed on them automatically (Chugunov M. V. et al, 2014) 3. User interface The user interface is released in two SolidWorks windows: Property Manager Page and Task Pane. The formulation of the optimization problem is depicted in Figure 1, Figure 2 and Figure 3: to maximize a volume (Figure 2) of the ellipsoid, using its semi-axises as the control parameters (variables) (Figure 3) so, that the ellipsoid’s surface area isn’t changed (Figure 4). Figure 2: Objective function defining Figure 3: Control variables defining Figure 4: Constraint functions defining So, “Objective function” property page includes Bitmap Picture, Combo Boxes, and List Box. In the case selection “Face”, “Edge” or “Vertex”, the user can define the entity by mouse clicking in the graphics area. List Box, placed on Control Variables Page lists all model dimensions, global variables and the equations. User selects the necessary parameter, pressing button ∇ and removing it to second List Box. Geometry Constraints are defined in Edit Boxes (on the right). Mikhail V. Chugunov1, Akexander V. Schekin Int. Journal of Applied Sciences and Engineering Research, Vol. 4, No. 4, 2015 496 Practical aspects for development of Add-In SolidWorks applications on example of optimization problems Constraints Page is created similar to Objective Function Page and has Bitmap Picture, Spin Control, Button List Box, two Combo Boxes and Edit Box. The most effective tool for dialogue realization is the library of the classes MFC (Microsoft Foundation Classes) (Shepherd G.and Kruglinski D., 2003). For the purpose of the dialogue realization in Property Page windows we developed a certain analog of MFC, which structure is shown on Figure 5. Figure 5: MFC analog structure We have to define our own Page-classes, the message maps and the macros. The macro, declaring the array, that will hold our message map entries and some pointers, used to find the message map of the base class. The root of the class hierarchy is the base SolidWorks interface IpropertyManagerPage2Handler3. We also use the DDX mechanism and overrided Do Data Exchange function. The following example (Figure 6) shows the Do Data Exchange override function, in which five DDX functions are called for the Constraints Property Page. This DDX functions shown are for a string, list-string, number-box and edit-text box controls, respectively. In the Figure 7 the dialog realization in the TaskPane window is depicted. Global variables are used: pSW is the smart SolidWorks (ISldWorks) interface pointer and wnd is the Task Pane view window pointer. Two classes, derived from CDialog, using recourses IDD_DIALOGTASKPANE and IDD_ SIMULWINDOWS respectively. void CConstraintsPage::DoDataExchange(CDataExchangeSW* pDX) { DDX_CBStringSW(pDX,1001,m_ConstraintName); DDX_CBStringSW(pDX,1005,m_ConstraintType); DDX_CBStringSW(pDX,2005,m_EntityParameter); DDX_LBStringSW(pDX,2003,m_EntityType); DDX_NumboxSW(pDX,5001,m_NumberConstrdouble); DDX_TextSW(pDX,1006,m_ConstrValue); } Figure 1: Do data exchange function Mikhail V. Chugunov1, Akexander V. Schekin Int. Journal of Applied Sciences and Engineering Research, Vol. 4, No. 4, 2015 497 Practical aspects for development of Add-In SolidWorks applications on example of optimization problems Figure 2: Task Pane dialog realization The first is the dialog panel, having simple controls for the problem option defining and for property manager page activation (top of the Task Pane) (Figure 8). The second is the window, created for the plotting of the search process of the optimum (bottom of the Task Pane). Figure8 represents the solving of the optimization problem in general; this problem is formulated by us for the ellipsoid’s volume maximization. Here the curves are the approximated optimization functions (volume and surface area) on 2D section for the optimization space, blue biggest rectangle is the sub-region, corresponding for the last search stage approximation, red small rectangle in the center of the sub-region is the optimum, green rectangles inside are the points, used for the least-squares method realization. In these points the optimization functions are defined exactly by SolidWorks. The search sub-region is drugged and dropped by the user moving the corner points by mouse (small rectangles on sub-region vertexes) into direction of the movement to the optimum, defined at the previous stage, and the black polyline is the path of the search. The optimal ellipsoid is close to the sphere in this test problem (Chugunov M. V., Nebaykina J.A., 2011). Figure 8: Optimization problem example 4. References 1. Chugunov M. V., Nebaykina J.A. 2011. Program module for solution of optimum design problem in SolidWorks software, based on API. Science and Education. BMSTU, 9, http://technomag.bmstu.ru/doc/206217.html (in Russia) 2. Chugunov M. V., Osyka V. V. Kudayev S. P., Kuzmichyov N. D., Klyomin V. V.,2014. Analysis and design of force rolling stock elements. Science and Education. BMSTU. 9, 216-226. (in Russia) Mikhail V. Chugunov1, Akexander V. Schekin Int. Journal of Applied Sciences and Engineering Research, Vol. 4, No. 4, 2015 498 Practical aspects for development of Add-In SolidWorks applications on example of optimization problems 3. Jun Wang, Xinyuan Huang, and Shengju Sang. 2011. Using Multiple Methods for Rapid Programming in SolidWorks. Applied Mechanics and Materials, 48-49, 1337-134. 4. Polynkin A.A. and Toropov V.V. 2012. Mid-range metamodel assembly building based on linear regression for large scale optimization problems. Structural and Multidisciplinary Optimization. 45(4), 515-527. 5. Rozvany G. I. N., 2009. A critical review of established methods of structural topology optimization. Struct Multidisc Optim. Springer-Verlag. 37(3), 217-237. 6. Shepherd G., Kruglinski D. 2003. Programming with Microsoft Visual C++. NET. Microsoft Press. 7. Toropov V.V. 1992. Multipoint approximation method in optimization problems with expensive function values /V.V. Toropov// In: Sydow, A. (ed.) Computational Systems Analysis, Elsevier, 207-212. Mikhail V. Chugunov1, Akexander V. Schekin Int. Journal of Applied Sciences and Engineering Research, Vol. 4, No. 4, 2015 499