GetVolume Activity

Purpose: This activity gets the volume of a SolidWorks part document. The volume is calculated based on the part geometry and is returned as a string with units. This is essential for mass calculations, material usage, and manufacturing cost estimation.

Input Properties

DocumentId

ID of an open SolidWorks document. This should be the document ID returned by activities like OpenSolidWorksFile or GetActiveDoc.

Type: string

Required: Yes

Example: "doc-12345"

Output Properties

Volume

The volume of the part as a string with units. The format includes the numeric value and unit designation (e.g., "1250.5 mm^3" or "1.25 cm^3").

Type: string

Note: If an error occurs, this will contain an error message starting with "Error: " or "Unexpected error: ".

Example: "1250.5 mm^3" or "1.25 cm^3" or "0.076 in^3"

Usage Example

Scenario: Get the volume of a part for material cost calculation

Configuration:
- DocumentId: "doc-12345"

Result:
- Volume: "1250.5 mm^3" (or error message if failed)

Next Steps:
Use the Volume value along with material density to calculate mass, or use it for material cost estimation.

Error Handling

Important: The activity handles errors gracefully:

  • If the document ID is invalid or the document cannot be found, an InvalidOperationException will be caught and Volume will contain: "Error: {error message}"
  • If the volume cannot be calculated (e.g., part is not fully defined or has errors), Volume will contain an error message
  • Any other unexpected errors will be caught and Volume will contain: "Unexpected error: {error message}"

Always check the Volume output to ensure it doesn't start with "Error:" before using it in calculations.

Important Notes

  • The document must be a SolidWorks part document (not an assembly or drawing)
  • The document must be open in SolidWorks and accessible via the DocumentId
  • The part must be fully defined and error-free for accurate volume calculation
  • Volume units depend on the document's unit system (MMGS, IPS, etc.)
  • The calculation is based on solid geometry - surfaces or open bodies may not return valid volume
  • Volume is essential for mass calculations when combined with material density
  • Use this activity in combination with GetPartMaterial to calculate mass accurately
  • Use HasFeatureTreeErrors to check for errors before calculating volume

Related Activities