# SolidWorks¶

Tag: Integration

This integration type block allows to apply optimization and other data mining techniques to SolidWorks parts and assemblies.

## Introduction¶

The SolidWorks block enables integrating SolidWorks models and SolidWorks Simulation static studies into your workflows. The block maps model or study properties to its input and output ports so they can be changed and read by pSeven. When this block runs, it receives values to input ports, changes model dimensions and global variables, rebuilds the model, recalculates mass properties, and sends resulting values to output ports. Optionally it can also save the changed model to disk or export it to a specified format. For models with added static studies, it can change restraints of a study and send its results to output ports.

Note that when the SolidWorks block executes, it actually launches SolidWorks, so the block can run only on a Windows host (since there is no SolidWorks version for Linux). Nevertheless, you can configure this block even when pSeven is running under Linux. Document tree exploration will be unavailable, since it requires starting SolidWorks; however, the tree can be built under Windows and saved to the block. Then, if you save the workflow and move your project to a Linux host, pSeven for Linux can use document information saved by the block.

The SolidWorks block launches the SolidWorks application in the following cases:

• when you select a document file (in order to look for document references),
• when you open the selected document from the block configuration dialog,
• when you get information from the document (build the document tree), and
• when actually rebuilding the model or running the study (at the workflow run-time).

If SolidWorks is already launched, the block connects to the running application. If a document with the same name is already open in SolidWorks, the block uses this document. This way you can work with the same model in SolidWorks and pSeven simultaneously.

## Compatibility¶

To run, the SolidWorks block requires SolidWorks installed. The block was tested with SolidWorks 2016 x64 SP0.1, SolidWorks 2014 x64 SP3.0, and SolidWorks 2012 x86 SP5.0; other versions are also compatible, but were not actively tested.

Prior to pSeven 6.0 RC 1, global variables with assigned units of measurement (for example, x = 5mm) were interpreted as read-only and could be mapped only to output ports. pSeven 6.0 RC 1 added the support for mapping such variables to input ports too. However, it works only if using SolidWorks 2015 or later due to a bug in earlier versions of SolidWorks. See also the pSeven 6.0 RC 1 section in Version Compatibility.

## Files Configuration¶

Document and export files configuration uses the generic file configuration component. Refer to the File block documentation when you need specific details.

### Document File¶

To select a SolidWorks document, click in the Document file pane. Note that some of the possible file configurations are invalid:

• The document cannot be a file of the project or sandbox origin with initial data.
• The document cannot be a file of the temporary origin.

The block supports SolidWorks parts (.sldprt), assemblies (.sldasm) and ZIP archives (.zip). If the document references other files, use File -> Pack and Go feature in SolidWorks to provide a zip file with all dependencies of the model.

### Export File¶

To select an export file, click in the Export file pane. Note that the export file cannot contain initial data.

The block supports export to the STEP (.step), IGES (.igs), STL (.stl), ACIS (.sat) and Parasolid (.x_t) formats. The document file can also be saved as a ZIP archive which will contain all referenced files, similarly to the archive obtained using Pack and Go in SolidWorks.

## Document Tree¶

After a SolidWorks document is selected, you can click on the Document Tree pane to get the list of its model dimensions, global variables, mass properties, model views, static study restraints and results.

In the tree you can select nodes that will be mapped to input and output ports. When you select a node, a new corresponding variable appears in the Variables list. The Ports column in this list shows which ports (input, output, or both) are created for the corresponding tree node.

The nodes in the views list are special. They allow to export model standard and named views as images in .png format. When you map such node, an output File port is created. If you set up monitoring for this port, the images will be saved in the project database during the workflow run, so you can display them with Page viewer on the Analyze screen.

### Structure¶

The SolidWorks block can work with dimensions of parts and assemblies (including contained subassemblies and parts), mass properties of any component in different configurations, global variables, model views, static study restraints and results. The document tree structure is as follows:

• Dimensions — lists all parts and assemblies, their features, and features’ dimensions.
• part name (for each part or assembly)
• feature name (for each part’s feature)
• dimension
• dimension
• ...
• Global variables — a flat list of global variables.
• variable
• variable
• ...
• Mass properties — lists mass properties for all document configurations.
• configuration name (for each available configuration)
• component name (for each component in this configuration)
• mass
• volume
• area
• Other properties: center of mass coordinates, moments of inertia.
• Views — a flat list of model views (standard and user-created).
• view name
• view name
• ...
• Simulations — lists restraints and results for simulation studies. Note that the block supports static studies only.
• Restraints — static studies’ restrains.
• study name (for each study)
• restraint
• restraint’s property
• restraint’s property
• ...
• another restraint
• property
• ...
• Results — study results.
• study name (for each study)
• Stress — calculated values of element and node stress.
• Elements — element stress values.
• Minimum — minimum stress.
• details...
• Maximum — maximum stress.
• details...
• Nodes — node stress values.
• Minimum — minimum stress.
• details...
• Maximum — maximum stress.
• details...
• Strain — calculated values of element and node strain. Same subtree structure as in Stress: elements and nodes, minimum and maximum strain.
• Displacement — calculated values of element and node displacement. Same subtree structure as in Stress.

Note that all values are taken from the configuration that was selected active in the document, except mass properties values that are available for all configurations. Moments of inertia in mass properties are calculated at the center of mass and aligned with the output coordinate system.

### Node Properties¶

Hovering a document tree node shows a tooltip with node’s properties: type, value and read-only state.

Type

Most dimensions, global variables, mass properties, restraints and results are of the RealScalar type, but some dimensions are IntScalar, views are of the File type. When you select a node in the document tree, it is mapped to a port of this type.

Value

Dimensional values that the block reads from and writes to ports are in SI units regardless of the document units. One notable exception is a global variable with assigned units of measurement: values of such variables are parsed directly from the equation (variable declaration). For example, the output value of a global variable “x” set by equation x = 5mm will be 5 (assigned units — millimeters), not 0.005 (SI meters). Likewise, if the value of “x” is changed to 10, the new equation will be: x = 10mm.

If you select a read-only node in the document tree, it is always mapped to an output port. Writeable nodes are mapped to input ports by default.

• mass properties,
• static study results,
• driven dimensions, and
• global variables defined by equations (for example: x = x1 + 2, x = 2m + 5mm).
• views

Note that if you map a read-only node (for example, “mass”) to an input port, a validation warning will appear in the Issues pane:

"mass" is read-only but mapped to input port.


The block can also raise this error at the run-time.

## Options¶

Consider as failure

When to consider model rebuild as failed.

Value: errors, errors and warnings errors and warnings

After rebuilding a part or an assembly, the block checks SolidWorks’ What’s Wrong. Any error present in What’s Wrong is always considered as a failure to rebuild. In addition, when Consider as failure is errors and warnings, warnings are also treated as a failure. The Error handling behavior option controls block’s further actions in case of failure.

Error handling behavior

The action to perform if the block encounters an error.

Value: stop workflow, output defaults and signal, output signal only stop workflow

When set to stop workflow, the block simply reports an error and the workflow interrupts.

If set to output defaults and signal, the block suppresses the error. Output ports in this case send values assigned to them (the defaults), and the done port outputs a False value (the signal). Note that the block automatically assigns values to output ports that are created when you select document tree nodes. The values are:

The output signal only behavior means to output only the False value to done; nothing is output to other ports.

Export/STEP

Specifies the STEP version number for files exported as STEP.

Value: AP203, AP214 AP203

Max steps

The maximum number of block startups that can use the same SolidWorks application instance.

Value: positive integer 50

Normally, the SolidWorks application started by the block is not closed after the block finishes (that is, until the workflow stops). Subsequent startups of the block use the same application instance to save time. However, each next model rebuild in SolidWorks can take more time; due to this it can be useful to restart the application sometimes. This option sets the number of block startups that are allowed to use the same running SolidWorks instance. When the limit is reached, SolidWorks is restarted.

This option works only when SolidWorks is started by the block. If the block connects to an instance of SolidWorks that you have started manually, this instance is never restarted.

SolidWorks executable path

Full path to the SolidWorks executable (SLDWORKS.exe).

Value: string empty

By default, the block determines the path to SolidWorks automatically. This option can be used to override the automatically found path. If specified, it also overrides the Version option.

SolidWorks wait timeout

The time in seconds to wait for the SolidWorks application to become available in case it is currently used by another SolidWorks block.

Value: positive integer 300

Several SolidWorks blocks in a workflow can start simultaneously — this is typically the case when there is a parallel Composite block containing SolidWorks blocks. In this case, only one of the SolidWorks blocks can connect to the SolidWorks application at a time (this is a SolidWorks limitation). Other blocks have to wait until SolidWorks becomes available, and will do so until the timeout is exceeded.

Exceeding the timeout raises an error which always stops the workflow. That is, the timeout error is never suppressed regardless of the Error handling behavior setting. The workflow is not terminated immediately: all blocks that are currently running continue their execution, and the workflow stops after they finish (soft stop). Note that setting the timeout to 0 will always trigger workflow stop if an SolidWorks block with zero timeout starts while there is another SolidWorks block running. The running block will be allowed to finish execution in this case, and the workflow will be stopped by the timeout error from the second block.

Version

The SolidWorks version to use.

Value: latest, 2012, 2013, 2014, 2015, 2016 latest

Changed in version 6.5: SolidWorks 2015 support.

Changed in version 6.7: SolidWorks 2016 support.

This option allows to choose the version to use if several versions of SolidWorks are installed.

Visible

Show the SolidWorks application window during run-time calculations.

Value: Boolean True (show the window)

If False, SolidWorks will be run in the background without showing a window. This option affects only the run-time. When you configure the block (build a document tree), SolidWorks is always launched in the background without showing a window.