Code development for the implementation of the Part Conditional Scale Feature in 3D CAD software platforms

. Most contemporary 3D CAD software has implemented the Scale feature as a plain multiplication or division of an object’s standard dimensions. A variety of options exists; sometimes the Scale process can be applied to an origin or a user-defined coordinate system, or it can be applied to one or two axes. No software so far has offered the option of setting the rules as to how the Scale feature can be applied to one or more components of an object. This article is about the development of a code that adds this functionality to a popular 3D CAD software. As a first step, the code is only applied to holes that lie on a planar face.


Introduction
In the process of Product Development, engineers often rely on the design of a product that has already been successfully manufactured, which they modify, with the aim of improving it [1]. Many times, a successful product needs to be modified so that it can be used in different applications, industries, consumer categories etc. from which it was originally developed. In order for a product to acquire additional or different properties, one of the most common modifications used by engineers is to change its dimensions. But the shape in which a successful product has been designed is almost always an important factor of its success. Thus, when attempting to improve it, the requirement is to change it as little as possible [2]. Given the above limitations, regarding the complexity of the product's geometry, the redesign process can be quite laborious and time consuming [3]. In order to solve this problem, all modern CAD software programs have implemented the Scale feature. The Scale feature can uniformly change the shape of an object, by a certain scale factor [4], which at a first glance seems to be the solution to the problem. However, in the real world the product is redesigned so that it has "almost" the same shape as the original. It is never "exactly" the original product multiplied by a number. A typical example of geometry that cannot be changed this way is the holes. Usually the holes are used to assemble the product components together or to fasten the product. The assembling as well as the fastening is done with standard connection elements (e.g screws, pins, etc.). However, all these connection elements also have standard dimensions. Therefore, by applying the Scale feature to the entire product, the holes should be excluded and modified individually. This article is about the development of an algorithm that applies the Scale command to the whole object, but then applies exclusion rules and individual scale rules to the holes that lie on planar surfaces, defined by the user. The algorithm was developed as an add-on to the DS SOLIDWORKS commercial software.

Methods
At first, a C++ dynamic link library (dll) project was created inside the Visual Studio Community 2017. Then, a code has been developed in order to embed the Add-on to the SOLIDWORKS software. More specifically, using the functions of the SOLIDWORKS Automated Program Interface (API), all necessary connections (Events) between the SOLIDWORKS software and the Add-on have been developed, toolbars, menu items and buttons have also been created inside the SOLIDWORKS Graphical User Interface (GUI). Then, the main dialog ( Fig. 1) of the Add-on has been designed. Scale feature is firstly applied on bodies; the main dialog bodies are selected and scale rules are defined (scale factor and scale type). The next step is to exclude holes from being scaled. For this purpose, an Exclude Feature Dialog (Fig. 2.) has been developed.
All hole features that must be excluded from the Scale operation are selected. For each hole feature, a reference face must be selected (e.g the inner face of the hole) and the face from which the hole distance must remain constant after the Scale process. There is also an option to input the distance value. For each hole, two position rules must be set, in order to determine the hole's final position on the planar surface (Fig. 3). All those rules are saved in memory. Now it is possible to calculate the coordinates of point X ( , , ), that is the center of the hole that we want to exclude from Scale process. Point X must preserve its distance ( 1 ) from Face1, Face2 ( 2 ) and Face3 3 , after the Scale process will have taken place. Firstly, the coefficients of the Face1, Face2 and Face3 planes equations must be calculated. SOLIDWORKS API has a function that returns a face's normal vector and the vector's root point. For reference face, Face1, the normal vector and the root point are for reference face Face2 are ⃗⃗ ( , , ) V ( , , ) and for the face on which the hole lies are ( , , ) N ( , , ) The equation of a plane is [5] because the normal vector of this plane is The plane equation can be written as follows: And because the root point P, lies on the plane, its coordinates must satisfy the plane's equation: From the above equation 1 can be calculated as follows: And by using the same methodology, 2 3 are calculated as follows: The distance of the point from the plane of Face1 The distance of the point X from the plane of Face1 is given by: The distance of the point X from the plane of Face3 is given by: where 3 = 0, because point X is a point on Face3.

Fig. 4.
Illustrating the positions of the four points, that abstain distance D1 from Face1 and distance D2 from Face2.
Next, by checking which of the four points lies on Face3, the coordinates of point X can be determined.
Now, by using the Hole Reference Face, the center of the hole can be calculated. If, is the center of the hole coordinates after the Scale process, then Hole Face must be moved as follows: Finally, by using the SOLIDWORKS API Move Face command, the face hole translation that has been previously calculated can be applied.

Typical example
The process explained in this article can be applied as illustrated below, in the example of a stainless-steel sheet metal part which is the outer cover of an electrical panel.
The electrical panel has a main power switch, which is fastened on the sheet metal cover by four bolts. The installation of the switch also needs a hole at the center for the switch button (Fig. 5). In this example, the electrical panel must be scaled at half the size, but the same main switch must be installed. The code described in this paper will be used in order to exclude the main switch holes from the Scale process.  The code is executed inside the SOLIDWORKS user interface. In the main dialog of the application the scale factor is set.
The next step is to exclude all the hole features of the main switch (CutExtrude, CutExtrude9, CutExcrude8, CutExtrude7 and CutExtrude6).In this step, all Hole features are selected, one by one. For each hole face, two reference faces are selected. The distance of the hole face and the reference faces will be preserved after the Scale process. The resulting sheet metal part, after running the code, is shown In Fig. 6.The upper cover of the electrical panel has been scaled, using a scale factor of 0.5, but the holes where the main switch will be installed remains unchanged and at the same distance from the reference faces.