How to Make Any Stir-Fried Noodles in 6 Steps. Tom Hirschfeld teaches us how to make stir-fried noodles with whatever's in the fridge. About 3 years ago Jeff Download/Read Craving (Steel Brothers Saga Book 1) ebook free pdf. - 3D Engineering Technology Prototyping. Naruto ninja destiny ii nds download itazura.
Free Pdf Book
Delcam Custom Software Core www.delcam-services.com
Custom Software Core User Guide - PowerSHAPE User Guide - PowerSHAPE ⢠1 Delcam Custom Software Core Copyright © 2011 - 2015 All rights reserved. Delcam Ltd has no control over the use made of the software described in this manual and cannot accept responsibility for any loss or damage howsoever caused as a result of using the software. Users are advised that all the results from the software should be checked by a competent person, in accordance with good quality control procedures. The functionality and user interface in this manual is subject to change without notice in future revisions of the software. The software described in this manual is furnished under licence agreement and may be used or copied solely in accordance with the terms of such licence. Delcam Ltd grants permission for licensed users to print copies of this manual or portions of this manual for personal use only. Schools, colleges and universities that are licensed to use the software may make copies of this manual or portions of this manual for students currently registered for classes where the software is used. Acknowledgements This documentation references a number of registered trademarks and these are the property of their respective owners. For example, Microsoft and Windows are either registered trademarks or trademarks of Microsoft Corporation in the United States. It is the responsibility of the licensee of Delcam's software to ensure that the storage and processing of any personal data complies with the appropriate legal regulations. User Guide - PowerSHAPE ⢠2 Contents Custom Software Core .............................................. 1 User Guide - PowerSHAPE 1 Introduction ....................................................... 4 What is Custom Software Core? .................................. 4 Installing CSC ................................................ 5 Learning to code with Custom Software Core ....................... 6 Examples ....................................................... 19 Example 1 - Creating a Cylinder ................................. 19 Example 2 - Cleaning a Mesh ................................... 22 User Guide - PowerSHAPE ⢠3 Introduction What is Custom Software Core? Custom Software Core, hereafter referred to as CSC, is an easy to use coding alternative to direct use of the macro language supplied by PowerSHAPE and PowerMILL. The power of CSC can be harnessed from within the Microsoft Visual Studio programming environment and used for creating both Delcam Automation addins and standalone executables. The programmer can choose to develop in either C# or VB.net. Advantages of the CSC approach to application development are as follows: ï§ Changes made to the macro language by PowerSHAPE and PowerMILL development teams are hidden from the developer, with version discrepancies being handled seamlessly by CSC. ï§ The developer is able to leverage all of the power provided by the VB.net and C# programming languages. ï§ Significantly fewer lines of code are required to perform like-for-like operations using CSC over direct macro language scripting, resulting in reduced complexity and shorter development times. Throughout this document: Notes have been written in both C# and VB.net and have been colour coded as follows: C# VB.net You will need a licensed copy of Microsoft Visual Studio 2010 or later to make use of Custom Software Core For versions of PowerSHAPE below 15.1.46, returned values will be in the language of the PCâs current culture; this can cause problems for Custom Software Core. To resolve this issue, add to the windows environment the variable âLC_ALL = Englishâ, which will force PowerSHAPE to run in English. The downside to this is that the UI will also be displayed in English. If, afterwards, you wish to revert the change, it is only necessary to delete the new environment variable. We recommend that, if running a 32Bit version of PowerSHAPE, you compile your applications as 32Bit; likewise, if you are running a 64Bit version of PowerSHAPE, compile in 64Bit. User Guide - PowerSHAPE ⢠4 Installing CSC Ensure you have downloaded the CSC installer onto your PC from the Delcam website, a link to which can be found in the same location as the link for this document. http://www.delcam.com/downloads/custom-core/index.asp To install the software, double click the installer and follow the instructions as required. Once your install is complete, you must ensure you have extracted and saved the example files for CSC in an accessible location on your local drive before proceeding. These files will be used throughout the remainder of the documentation. User Guide - PowerSHAPE ⢠5 Learning to code with Custom Software Core To begin with, we will look at some of the more common tasks performed with CSC such as starting a new project, connecting to PowerSHAPE, creating simple models and so forth. After this we will look at some examples where macro code can be replaced with CSC. Creating a Project 1 Open up Microsoft Visual Studio and start a new project. 2 Select âVisual C#â or âVisual Basicâ (based on your preference) from the options on the left, then select âConsole Applicationâ (Figure 1). 3 Give the project a name and a save location (Figure 1). Figure 1 â New Project 4 Your main project source file will contain the following code: using using using using using System; System.Collections.Generic; System.Linq; System.Text; System.Threading.Tasks; namespace Example1 { class Program { static void Main(string[] args) { } } } User Guide - PowerSHAPE ⢠6 Module Module1 Sub Main() End Sub End Module 5 The next step is to set references to custom software core. Figure 2 shows a reference diagram detailing the dependencies for each reference. Delcam.Utilities Delcam.Geometry Delcam.ProductInterface Delcam.ProductInterface. PowerSHAPE Delcam.ProductInterface. PowerMILL Figure 2 â Reference Diagram 6 To add the required references, right click on âReferencesâ within your solution in the Solution Explorer on the left and then select âAddâ then âReferenceâ (Figure 3). Figure 3 â Add Reference User Guide - PowerSHAPE ⢠7 7 From within the window that now appears, select âAssembliesâ and then âExtensionsâ from the list. 8 Navigate the list of references and select the following: 9 ï§ Delcam.Geometry ï§ Delcam.ProductInterface ï§ Delcam.ProductInterface.PowerSHAPE ï§ Delcam.Utilities With the references added, insert the following using directive at the top of your source file: using Delcam.ProductInterface.PowerSHAPE; Imports Delcam.ProductInterface.PowerSHAPE This will save repeatedly typing in Delcam.ProductInterface.PowerSHAPE when accessing items within this class Connecting to PowerSHAPE The following section demonstrates how CSC can be used to communicate with a running instance of PowerSHAPE; required is a running instance of PowerSHAPE with an active model. 1 Start an instance of PowerSHAPE. 2 To access the PowerSHAPE instance, add the following line to the main method of your source file: PSAutomation powerSHAPE = new PSAutomation (Delcam.ProductInterface.InstanceReuse.UseExistingInstance); Dim powerSHAPE As New PSAutomation(Delcam.ProductInterface. InstanceReuse.UseExistingInstance) While typing this line IntelliSense gives a number of options. For example, after InstanceReuse we have options to: create a new instance (in addition to any existing instance of PowerSHAPE); Create a single instance (close any PowerSHAPE instances already open and create a new one) or UseExistingInstance (attach to a running instance of PowerSHAPE). If you continue the line by typing a â.â after your selection of InstanceReuse, you are presented with a number of additional options including the mode in which to open PowerSHAPE (drafting, pro, toolmaker, for example) and the version and/or maximum version of the PowerSHAPE installation to run. 3 After attaching to PowerSHAPE it is often desirable to reset the list of available models, thereby closing them, and open a new one. This can be achieved as follows: powerSHAPE.Reset(); powerSHAPE.Reset() User Guide - PowerSHAPE ⢠8 4 To attach to the active PowerSHAPE model, add the following code to the main method: PSModel psModel = powerSHAPE.ActiveModel; Dim psModel As PSModel = powerSHAPE.ActiveModel() Alternatively, to create a new model rather than attach to that which is currently active, use: PSModel psModel = powerSHAPE.Models.CreateEmptyModel(); Dim psModel As PSModel = powerSHAPE.Models.CreateEmptyModel() 5 When controlling PowerSHAPE remotely in this manner, it is important to disable all forms and dialogs; doing so increases the speed at which operations complete. Add the following code to the main method: powerSHAPE.FormUpdateOff(); powerSHAPE.RefreshOff(); powerSHAPE.DialogsOff(); powerSHAPE.FormUpdateOff() powerSHAPE.RefreshOff() powerSHAPE.DialogsOff() 6 These will need to be re-enabled before the application exits for PowerSHAPE to function normally. Add the code to do this now and all subsequent code in between this and the previous block. powerSHAPE.FormUpdateOn(); powerSHAPE.RefreshOn(); powerSHAPE.DialogsOn(); powerSHAPE.FormUpdateOn() powerSHAPE.RefreshOn() powerSHAPE.DialogsOn() 7 Type psModel into the main method (refer to the previous step to ensure you add it in the right place) followed by a full stop (period). IntelliSense reveals a list of methods that can be invoked on the model and a selection of properties that can be retrieved or set. The following sections will explore a small subset of the operations that can be performed on PowerSHAPE using CSC. User Guide - PowerSHAPE ⢠9 Creating Geometry Figure 4 below details a CSC PowerSHAPE class hierarchy. PSAutomation contains a PSModel, which contains collections of arcs, curves, lines and so forth, each containing one or more objects of its type. Objects can be added to and removed from collections and the objects themselves manipulated with the various operations available on them: in short, a typical object oriented strategy. PSAutomation Active Model PSModel PSArcsCollection * PSArc PSCurvesCollection * PSCurve PSLinesCollection * PSLine PSSolidsCollection * PSSolid Figure 4 â Class Diagram As a simple introduction we will create a line between two points. 1 Two Delcam.Geometry.Point objects are used to define the start and end points of the line and are created with the following code, which should be added to the main method of the application source file. Delcam.Geometry.Point startPoint = new Delcam.Geometry.Point(0,0,0); Delcam.Geometry.Point endPoint = new Delcam.Geometry.Point(10, 5, 0); Dim startPoint As Delcam.Geometry.Point = New Delcam.Geometry.Point(0, 0, 0) Dim endPoint As Delcam.Geometry.Point = New Delcam.Geometry.Point(10, 5, 0) startPoint is initialised with coordinates (0, 0, 0), which is the origin of the model, and endpoint is given the coordinates (10, 5, 0), which represents displacement in both X and Y. User Guide - PowerSHAPE ⢠10 2 The two points can now be passed to PowerSHAPE and a line drawn between them: PSLine myLine = psModel.Lines.CreateLine(startPoint, endPoint); Dim myLine As PSLine = psModel.Lines.CreateLine(startPoint, endPoint) PSLine myLine holds a reference to the newly created PowerSHAPE object and is defined in the Delcam.ProductInterface.PowerSHAPE namespace. 3 The code can now be tested. Ensure there is an open session of PowerSHAPE to connect to, click the âStartâ icon in Microsoft Visual Studio and observe the PowerSHAPE active window where a line will be created. If any problems are encountered, review all previous steps to this point and ensure they have been completed in accordance with the document. 4 The line can now be manipulated in code via the PSLine object it is mapped to (myLine). As an example, let us return the length of the line and store it as a delcam.geometry.MM length object. Add the following code to the main method: Delcam.Geometry.MM lineLength = myLine.Length; Dim lineLength As Delcam.Geometry.MM = myLine.Length Lengths are stored in a Delcam.Geometry.MM as it facilitates length-specific operations such as converting to inches: Inch inchLength = (Inch)lineLength; Dim inchLength As Inch = CType(lineLength, Inch) Custom Software Core always assumes the PowerSHAPE session to be running in mm; thus the return value will always be treated as mm. If you attempted the following: Delcam.Geometry.Inch sizeX = myModel.BoundingBox.MaxX with a session running in inches, the result would be read in Inches but then multiplied by 25.4 as CSC assumes it to be in mm. 5 Create a message box to display the line length. Firstly add a reference to Window.Systems.Forms by right clicking on your project in the Solution Explorer and selecting âAddâ then âAdd Referenceâ from the list. Select âAssembliesâ from the left then âFrameworkâ from the resulting drop down. Select System.Windows.Forms from the list and click âOKâ. 6 Add a using directive to the top of the main source file: using System.Windows.Forms; Imports System.Windows.Forms; 7 Instantiate a message box in which to display the line length. Add the following code to the main method: MessageBox.Show('The line is ' + lineLength.ToString() + 'mm'); MessageBox.Show('This line is' & lineLength.ToString & ' mm') 8 Run the code once more and a message box will appear (Figure 5). User Guide - PowerSHAPE ⢠11 Figure 5 â Line Length Message Box Creating Solids, Surfaces and Meshes We shall now see how CSC can be used to create other objects in PowerSHAPE by defining a simple solid block. 1 Delete from your main method all lines of code added in the previous section including points, lines and message box. 2 To create a simple block enter the following code: PSSolid mySolid = psModel.Solids.CreateBlock(startPoint, 25, 50, 10, 0); Dim mySolid As PSSolid = psModel.Solids.CreateBlock(startPoint,25,50,10,0) 3 This creates a block at the origin (0, 0, 0) of 25mm length, 50mm width, 10mm height and with a draft angle of 0â°. 4 Many operations can now be performed from within code on the newly created solid through its PSSolid reference object. If, for example, it is desired to delete the solid from PowerSHAPE, enter the following: mySolid.Delete(); mySolid.Delete() 5 With the addition of a single line of code a mesh can be created from the solid: PSMesh myMesh = psModel.Meshes.CreateMeshFromSolid(mySolid); Dim myMesh As PSMesh = psModel.Meshes.CreateMeshFromSolid(mySolid) 6 Alternatively, the solid can be turned into surfaces thus: List newSurface = psModel.Surfaces.CreateSurfacesFromSolid(mySolid); Dim newSurface As List(Of PSSurface) = psModel.Surfaces.CreateSurfacesFromSolid(mySolid) Surfaces must be stored in a list as such transforms may return many; six in the case of a cube. 7 Delete all code entered in this section before moving to the next. User Guide - PowerSHAPE ⢠12 Importing and Exporting a Model It is common practice to import and export solids, surfaces and so forth in PowerSHAPE. This section will focus on how to achieve this using CSC. 1 Create an instance of Delcam.FileSystem.File with which to encapsulate an import file location: Delcam.FileSystem.File importFile = new Delcam.FileSystem.File(@'C:CSC PowerSHAPE ExamplesExample.dgk'); Dim importFile As Delcam.FileSystem.File = New Delcam.FileSystem.File('C:CSC PowerSHAPE ExamplesExample.dgk') Example.dgk will be located in the path to which you extracted your example files earlier and may be different to that specified above. 2 Import the DGK file into the model: psModel.Import(importFile); psModel.Import(importFile) 3 The solid has now been imported into the open model. To obtain an instance of it from the solids collection enter the following line of code: PSSolid mySolid = psModel.Solids.LastItem(); Dim mySolid As PSSolid = psModel.Solids.LastItem 4 The solid can now be manipulated as before. The same principle can be applied to surfaces, meshes, curves and so forth. 5 To export the solid, it is first necessary to ensure it is the only selected object. The following two lines of code clear all selected items and then reselect the object that is to be exported. psModel.ClearSelectedItems(); mySolid.AddToSelection(); psModel.ClearSelectedItems() mySolid.AddToSelection() 6 The solid will now be exported back to its original file and location: psModel.Export(importFile, ExportItemsOptions.Selected); psModel.Export(importFile, ExportItemsOptions.Selected) Executing Macro Commands It is also possible to execute macro commands from within our code, the mechanism for doing which is outlined in the following. 1 Create a simple block using macro commands. Note this is purely for demonstration purposes since a similar result was achieved earlier using CSC functions. powerSHAPE.Execute('CREATE SOLID BLOCK'); powerSHAPE.Execute('BLOCK'); powerSHAPE.Execute('0,0,0'); powerSHAPE.Execute('CREATE SOLID BLOCK') User Guide - PowerSHAPE ⢠13 powerSHAPE.Execute('BLOCK') powerSHAPE.Execute('0,0,0') 2 Alternatively you may wish to acquire information from PowerSHAPE to use within your program. If, for example, you want to find the length of a line, enter the following: Double lineLength2 = (Double)powerSHAPE.ExecuteEx('line[TempLine].length'); Dim lineLength2 As Double = powerSHAPE.ExecuteEx('line[TempLine].length') You will need to know the name of the line to perform this operation. 3 It is important to note that entities created within PowerSHAPE using macro commands will not appear within the CSC cache until it is updated. To update the cache, issue the following command: psModel.Refresh(); psModel.Refresh() 4 It is now possible to create in code an instance of the PowerSHAPE object that was created with the macro command. If, for example, you create a line in macro code, create a PSLine instance as follows: powerSHAPE.Execute('CREATE LINE SINGLE'); powerSHAPE.Execute('0 0 0'); powerSHAPE.Execute('10 0 0'); psModel.Refresh(); PSLine myLine = psModel.Lines[0]; powerSHAPE.Execute('CREATE LINE SINGLE') powerSHAPE.Execute('0 0 0') powerSHAPE.Execute('10 0 0') psModel.Refresh() Dim myLine As PSLine = psModel.Lines(0) It is strongly recommended that you always use available CSC functionality in preference to issuing raw macro commands. If you feel that CSC is lacking the functionality you require, please contact the forum at: http://forum.delcam.com/viewforum.php?f=53 Deploying Solutions Once your development is complete, you will need a way of deploying your application to end users. This section will guide you through the process of creating an installer. Note that the end user will require a licensed copy of CSC installed on their target system in order to execute your application. 1 Begin by ensuring that the Microsoft Visual Studio Installer Projects extension is installed within your copy of Microsoft Visual Studio. If not, select âToolsâ followed by âExtensions and Updatesâ; now locate the extension from within the resulting window and install it. 2 Next, right click on your solution and select âAddâ then âNew Projectâ (Figure 6). User Guide - PowerSHAPE ⢠14 Figure 6 â Adding a new project 3 Select âOther Project Typesâ followed by âVisual Studio Installerâ from the left-handside of the new window; then select âSetup Projectâ. 4 Now configure a Manufacturer and Product Name. Select âSetup1â from within Solution Explorer and edit the Manufacturer and ProductName fields in the Properties tab as demonstrated in figure 7. Note: If the Properties tab is not visible, select it from the View menu. Figure 7 â Setting Manufacturer, ProductName User Guide - PowerSHAPE ⢠15 5 Right click the âApplication Folderâ from within the File System window to the right of Solution Explorer. Select âAddâ and then select âProject Outputâ from the resultant context menus (Figure 8). Figure 8 â Adding a project output If you cannot see the File System window, select âFile System Editorâ from the Solution Explorer toolbar (Figure 9). Figure 9 â File System Editor 6 From the dialog box, select âPrimary Outputâ and click âOkâ. 7 You will notice references appear in the right hand box (Figure 10). Figure 10 â Adding References 8 As it is a requirement that the end user install CSC, the Delcam references are not required and should be excluded from the project. Select each in turn and set âExcludeâ to True in the Properties tab. 9 If it is desired to add a shortcut to the start menu then right click âUserâs Programâs Menuâ and select âAddâ followed by âFolderâ; name the folder appropriately (Figure 11). User Guide - PowerSHAPE ⢠16 Figure 11 â Set an install folder 10 Right click the newly created folder and select âCreate New Shortcutâ. 11 Select the new folder and, in the empty panel to the right, right click and select âCreate new shortcutâ. Figure 12 â Adding shortcut to program menu 12 In the resulting dialog, double click the âApplication Folderâ and select the item starting with âPrimary output fromâ¦â Rename it to whatever you wish. 13 To create the installer, right click âSetup1â from within Solution Explorer and select âBuildâ. Once the operation has completed, browse to the location of the solution on the local drive, open Setup1 and then browse to either the Release or Debug folder - depending upon your solution settings â and the installer will be available therein. User Guide - PowerSHAPE ⢠17 User Guide - PowerSHAPE ⢠18 Examples Example 1 - Creating a Cylinder Example 1 demonstrates how to use CSC to create a circle in PowerSHAPE, extrude it to form a solid and then export the result to file. For comparison, macro code to accomplish the same task is presented below. CREATE ARC FULL 0,0,0 MODIFY DIMENSION 20 ACCEPT CREATE SOLID EXTRUSION MODIFY LENGTH 50 ACCEPT FILE EXPORT WIZARD NEXT C:CSC PowerSHAPE ExamplesCylinder.dgk WIZEXPORT The CSC steps are as follows: 1 Start a new console application in Microsoft Visual Studio as detailed previously. 2 Add the following references to your solution (if you have forgotten how to do this refer back). 3 ï§ Delcam.Geometry ï§ Delcam.ProductInterface ï§ Delcam.ProductInterface.PowerSHAPE ï§ Delcam.Utilities Add the following using directive to the top of the main source file. using Delcam.ProductInterface.PowerSHAPE; Imports Delcam.ProductInterface.PowerSHAPE 4 Connect to PowerSHAPE and turn off all dialogs as before. PSAutomation powerSHAPE = new PSAutomation(Delcam.ProductInterface.InstanceReuse.UseExistingInstance); PSModel psModel = powerSHAPE.ActiveModel; powerSHAPE.FormUpdateOff(); powerSHAPE.RefreshOff(); powerSHAPE.DialogsOff(); Dim powerSHAPE As PSAutomation = New PSAutomation(Delcam.ProductInterface.InstanceReuse.UseExistingInstance) Dim psModel As PSModel = powerSHAPE.ActiveModel powerSHAPE.FormUpdateOff() powerSHAPE.RefreshOff() powerSHAPE.DialogsOff() User Guide - PowerSHAPE ⢠19 5 It is usually desirable to re-enable forms and dialogs before the program exits. Add this code now and all subsequent lines between this and the previous block. powerSHAPE.FormUpdateOn(); powerSHAPE.RefreshOn(); powerSHAPE.DialogsOn(); powerSHAPE.FormUpdateOn() powerSHAPE.RefreshOn() powerSHAPE.DialogsOn() 6 Two points are required to create a circle; the first is the origin of the circle and the second the position at which the circle starts (typically this is of no concern, but is required by CSC). The following code creates a circle centred at (0, 0, 0) and starting from the x-axis (the co-ordinate position of this point is not important so long as it lies on the axis). Delcam.Geometry.Point originPoint = new Delcam.Geometry.Point(0,0,0); Delcam.Geometry.Point startPoint = new Delcam.Geometry.Point(10, 0, 0); PSArc myCircle = psModel.Arcs.CreateArcCircle(originPoint, startPoint, 20.0); Dim originPoint As Delcam.Geometry.Point = New Delcam.Geometry.Point(0, 0, 0) Dim startPoint As Delcam.Geometry.Point = New Delcam.Geometry.Point(10, 0, 0) Dim myCircle As PSArc = psModel.Arcs.CreateArcCircle(originPoint, startPoint, 20) 7 The circle will now be extruded by 50.0 mm in the positive to form a solid. PSSolid myCylinder = psModel.Solids.CreateSolidExtrusionFromWireframe(myCircle, 50.0, 0.0); Dim myCylinder As PSSolid = psModel.Solids.CreateSolidExtrusionFromWireframe(myCircle, 50, 0) 8 The cylinder thus formed can now be exported by firstly creating a Delcam.FileSystem.File object initialised with an appropriate export path and then writing the data to it. Delcam.FileSystem.File exportLocation = new Delcam.FileSystem.File(@'C:CSC PowerSHAPE ExamplesCylinder.dgk'); psModel.Export(exportLocation, ExportItemsOptions.Selected); Dim exportLocation As New Delcam.FileSystem.File('C:CSC PowerSHAPE ExamplesCylinder.dgk') psModel.Export(exportLocation, ExportItemsOptions.Selected) 9 The code can now be run. If the result is not as expected, ensure you have followed verbatim all he steps in this example. It is worthy of note that, should the code required to disable and re-enable forms and dialogs be excluded from the count, the number of lines required to accomplish our objective here is six, eight fewer than the macro code solution. using using using using using using System; System.Collections.Generic; System.Linq; System.Text; System.Threading.Tasks; Delcam.ProductInterface.PowerSHAPE; namespace CylinderExample User Guide - PowerSHAPE ⢠20 { class Program { static void Main(string[] args) { PSAutomation powerSHAPE = new PSAutomation(Delcam.ProductInterface.InstanceReuse.UseExistingInstance); PSModel psModel = powerSHAPE.ActiveModel; powerSHAPE.FormUpdateOff(); powerSHAPE.RefreshOff(); powerSHAPE.DialogsOff(); Delcam.Geometry.Point originPoint = new Delcam.Geometry.Point(0,0,0); Delcam.Geometry.Point startPoint = new Delcam.Geometry.Point(10, 0, 0); PSArc myCircle = psModel.Arcs.CreateArcCircle(originPoint, startPoint, 20.0); PSSolid myCylinder = psModel.Solids.CreateSolidExtrusionFromWireframe(myCircle, 10.0, 0.0); Delcam.FileSystem.File exportLocation = new Delcam.FileSystem.File(@'C:CSC PowerSHAPE ExamplesCylinder.dgk'); psModel.Export(exportLocation, ExportItemsOptions.Selected); powerSHAPE.FormUpdateOn(); powerSHAPE.RefreshOn(); powerSHAPE.DialogsOn(); } } } Imports Delcam.ProductInterface.PowerSHAPE Module Module1 Sub Main() Dim powerSHAPE As PSAutomation = New PSAutomation(Delcam.ProductInterface.InstanceReuse.UseExistingInstance) Dim psModel As PSModel = powerSHAPE.ActiveModel powerSHAPE.FormUpdateOff() powerSHAPE.RefreshOff() powerSHAPE.DialogsOff() Dim originPoint As Delcam.Geometry.Point = New Delcam.Geometry.Point(0, 0, 0) Dim startPoint As Delcam.Geometry.Point = New Delcam.Geometry.Point(10, 0, 0) Dim myCircle As PSArc = psModel.Arcs.CreateArcCircle(originPoint, startPoint, 20) Dim myCylinder As PSSolid = psModel.Solids.CreateSolidExtrusionFromWireframe(myCircle, 50, 0) Dim exportLocation As New Delcam.FileSystem.File('C:CSC PowerSHAPE ExamplesCylinder.dgk') psModel.Export(exportLocation, ExportItemsOptions.Selected) powerSHAPE.FormUpdateOn() powerSHAPE.RefreshOn() User Guide - PowerSHAPE ⢠21 powerSHAPE.DialogsOn() End Sub End Module Example 2 - Cleaning a Mesh Consider the case of importing a .STL scan file, the mesh of which contains a number of undesired detached pieces that are to be removed, thereby leaving only the largest piece of the mesh. To achieve this it is necessary to split the mesh into its individual pieces, consider each one in turn, retain the largest and export this back to file. A macro code solution requires IF statements, which can be confusing and difficult; the following steps demonstrate how the problem can be solved using CSC. 1 Start by adding the required references along with the following standard code with which you should now be familiar. using using using using using using System; System.Collections.Generic; System.Linq; System.Text; System.Threading.Tasks; Delcam.ProductInterface.PowerSHAPE; namespace CleanUpMesh { class Program { static void Main(string[] args) { PSAutomation powerSHAPE = new PSAutomation(Delcam.ProductInterface.InstanceReuse.UseExistingInstance); PSModel psModel = powerSHAPE.ActiveModel; powerSHAPE.FormUpdateOff(); powerSHAPE.RefreshOff(); powerSHAPE.DialogsOff(); powerSHAPE.FormUpdateOn(); powerSHAPE.RefreshOn(); powerSHAPE.DialogsOn(); } } } Imports Delcam.ProductInterface.PowerSHAPE Module Module1 Sub Main() Dim powerSHAPE As New PSAutomation(Delcam.ProductInterface.InstanceReuse.UseExistingInstance) Dim psModel As PSModel = powerSHAPE.ActiveModel powerSHAPE.FormUpdateOff() powerSHAPE.RefreshOff() powerSHAPE.DialogsOff() powerSHAPE.FormUpdateOn() User Guide - PowerSHAPE ⢠22 powerSHAPE.RefreshOn() powerSHAPE.DialogsOn() End Sub End Module 2 Create a Delcam.FileSystem.File object with which to import the .STL file and create a second file object to which the final result will be exported. Delcam.FileSystem.File importFile = new Delcam.FileSystem.File(@'C:CSC PowerSHAPE ExamplesSampleMesh.stl'); Delcam.FileSystem.File exportFile = new Delcam.FileSystem.File(@'C:CSC PowerSHAPE ExamplesSplitMesh.dmt'); psModel.Import(importFile); PSMesh myMesh = psModel.Meshes.LastItem(); Dim importFile As New Delcam.FileSystem.File('C:CSC PowerSHAPE ExamplesSampleMesh.stl') Dim exportFile As New Delcam.FileSystem.File('C:CSC PowerSHAPE ExamplesSplitMesh.dmt') psModel.Import(importFile) Dim myMesh As PSMesh = psModel.Meshes.LastItem 3 Split the mesh and store in a list the pieces returned by PowerSHAPE. List meshList = myMesh.Split(); Dim meshList As List(Of PSMesh) = myMesh.Split 4 Cycle through each entity to determine the largest bounding box. This can be achieved with a single line of code: meshList.OrderBy(m => m.BoundingBox.Volume).Last().AddToSelection(true); meshList.OrderBy(Function(m) m.BoundingBox.Volume).Last.AddToSelection(true) 5 Now only the largest piece of the mesh is selected PowerSHAPE, it can be exported to file in the manner described earlier in the document. psModel.Export(exportFile, ExportItemsOptions.Selected); psModel.Export(exportFile, ExportItemsOptions.Selected) It should be noted that a complex operation has been reduced to a small number of concisely written and easy to comprehend lines of code, the full listing of which is given below. using using using using using using System; System.Collections.Generic; System.Linq; System.Text; System.Threading.Tasks; Delcam.ProductInterface.PowerSHAPE; namespace CleanUpMesh { class Program { static void Main(string[] args) { PSAutomation powerSHAPE = new PSAutomation(Delcam.ProductInterface.InstanceReuse.UseExistingInstance); powerSHAPE.Reset(); User Guide - PowerSHAPE ⢠23 PSModel psModel = powerSHAPE.ActiveModel; powerSHAPE.FormUpdateOff(); powerSHAPE.RefreshOff(); powerSHAPE.DialogsOff(); Delcam.FileSystem.File importFile = new Delcam.FileSystem.File(@'C:CSC PowerSHAPE ExamplesSampleMesh.stl'); Delcam.FileSystem.File exportFile = new Delcam.FileSystem.File(@'C: CSC PowerSHAPE Examples SplitMesh.dmt'); psModel.Import(importFile); PSMesh myMesh = psModel.Meshes.LastItem(); List meshList = myMesh.Split(); meshList.OrderBy(m => m.BoundingBox.Volume).Last().AddToSelection(true); psModel.Export(exportFile, ExportItemsOptions.Selected); powerSHAPE.FormUpdateOn(); powerSHAPE.RefreshOn(); powerSHAPE.DialogsOn(); } } } Imports Delcam.ProductInterface.PowerSHAPE Module Module1 Sub Main() Dim powerSHAPE As New PSAutomation(Delcam.ProductInterface.InstanceReuse.UseExistingInstance) Dim psModel As PSModel = powerSHAPE.ActiveModel powerSHAPE.FormUpdateOff() powerSHAPE.RefreshOff() powerSHAPE.DialogsOff() Dim importFile As New Delcam.FileSystem.File('C:CSC PowerSHAPE ExamplesSampleMesh.stl') Dim exportFile As New Delcam.FileSystem.File('C:CSC PowerSHAPE ExamplesSplitMesh.dmt') psModel.Import(importFile) Dim myMesh As PSMesh = psModel.Meshes.LastItem Dim meshList As List(Of PSMesh) = myMesh.Split meshList.OrderBy(Function(m) m.BoundingBox.Volume).Last.AddToSelection(True) psModel.Export(exportFile, ExportItemsOptions.Selected) powerSHAPE.FormUpdateOn() powerSHAPE.RefreshOn() powerSHAPE.DialogsOn() End Sub End Module User Guide - PowerSHAPE ⢠24 User Guide - PowerSHAPE ⢠25 learn: www.delcam.tv/lz watch: www.delcam.tv visit: www.delcam-services.com Delcam Small Heath Business Park, Birmingham B10 0HJ UK +44 (0)121 766 5544 | [email protected] www.delcam-services.com © Copyright Delcam Ltd 2015. All trademarks are the property of their respective owners.
To install:-
Powershapes Pdf Book Download Free
Important Notes:
Power Shapes Pdf Book Download Free Download
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |