A CAD Forge Max extension is a small C# console program that CAD Forge Max runs on the product structure of a 3D Library element. This page describes what an extension is made of, and the contract between your program and CAD Forge Max. To set up your machine, see Getting started – C# Dev environment.
Anatomy of an extension
|
File |
Role |
|---|---|
|
|
Describes the job: its name, the executable to run and its settings. |
|
|
Describes the package for the Marketplace (name, description, |
|
|
The console program. It references the |
The .skrjob file
{
"JobName": "Merge structure",
"ScriptRelativePath": "skrmergestructure/Skr.MergeStructure.exe",
"DefaultSettings": {
"Values": {
"mergeStrategy": { "Value": "PartLimit", "ValueType": "String" },
"mergePartLimit": { "Value": "1000", "ValueType": "Integer" }
}
}
}
|
Field |
Role |
|---|---|
|
|
Unique name of the job in CAD Forge Max. Also the prefix of its settings (see below). |
|
|
Path of the executable, relative to the folder of the |
|
|
The settings of the job and their default values. |
|
|
|
The program contract
CAD Forge Max launches your executable like this:
Skr.MergeStructure.exe <workingDirectory> -mergeStrategy Metadata -metadataName InstanceName -metadataValue planes.1
|
Item |
Rule |
|---|---|
|
First argument |
The task working directory. Read it with |
|
Next arguments |
|
|
Exit code |
|
|
Progress |
|
|
Logs |
Use the logger from |
Setting values are passed without quotes: a value that contains spaces is cut at the first space.
Read the input
Create a Product3DComponentsContextHelper with the working directory, then:
|
Method |
Returns |
|---|---|
|
|
All the product components of the element (structure, metadata, materials, transforms). |
|
|
All the parts. |
|
|
The meshes of the parts. |
|
|
For each part, the product components that use it. |
Declare the output
Your program writes its changes in the Output folder, then always writes a declaration file with WriteOutputDeclarationFile (even empty, when there is nothing to change). CAD Forge Max applies only what is declared:
|
Declaration |
File to write |
Effect |
|---|---|---|
|
|
|
Replaces the whole product structure. |
|
|
|
Adds or updates the components you write. |
|
|
— |
Removes the components whose IDs are listed. |
|
|
|
Adds or updates parts and their meshes. |
|
|
— |
Declares the visualization engines your meshes target. |
See the Examples for complete programs.