Table of Contents
Applying Tools from Command Line
LinkCAD has extensive support for controlling the conversion process from the command line.
The following documentation explains how to apply various LinkCAD tools from the command line.
Automating Conversion
LinkCAD conversion tasks can be automated by means of command line arguments, as described in the LinkCAD help file, chapter “Customization Guide”. The following parameters are of particular interest in this context:
LcImportFormat
selects the import formatLcExportFormat
selects the export formatLcImportFile
or-i
specifies the file to importLcExportFile
or-o
specifies the converted fileLcSkipSteps
specifies which part of the LinkCAD user interface to hide (eg.-LcSkipSteps=all
)
This document describes the command line argument ToolApply
, which is used to apply a series of transformations to the imported file.
ToolApply Syntax
In order to apply a tool command to the loaded file, one of the following commands needs to be specified using the ToolApply
command line argument. The general syntax is:
-ToolApply=cmd1;cmd2;cmd3;...
where cmdn
is any of the command below. They will be applied in the order specified; you can even run the same command, with the same or different parameters, several times.
ToolApply
parameter.
The following lists the various commands that may be specified using the ToolApply
parameter.
Setting Processing Modes
This section lists all valid ToolApply
commands that can be used to specify various processing modes for the tool commands described in the next section.
SetUnits(unit-name)
- unit-name is one of
nm
|um
|mil
|point
|mm
|cm
|in
|m
|ft
|pm
.
This sets the units to be used by any tool following this command. You can change units as many times as needed.
-ToolApply=SetUnits(mm);JoinOpenPolylines(120)
SetResolution(value)
- value is either a number or a number and a unit (as in unit-name in
SetUnits
, but alsodpi
is possible).
Sets the resolution to be used for following tools (default is taken from ToolArcPrecValue
and ToolArcPrecUnits
if SetResolution
is not specified). You can change resolution as many times as needed.
-ToolApply=SetResolution(32);SetUnits(mm);JoinOpenPolygons(120)
-ToolApply=SetResolution(10nm);SetUnits(mm);JoinOpenPolygons(120)
SetFillRule(rule)
- rule is either
NonZero
orEvenOdd
.
This selects the fill rule to be used by tools following this command, and that rely on this setting. If absent, the default is taken from the option parameter -ToolEvenOddFill
.
SetHolesMode(mode)
- mode is either
Link
orSplit
.
This selects the hole split mode used by tools following this command, and that rely on this setting. If absent, the default is taken from the option parameter -ToolDeembedCutLines
.
SetEdgePolicy(policy)
- policy is either
Merge
orKeep
.
This specifies how to handle internal edges during a Boolean operation, such as MergeOverlappingPolygons
. If absent, the default is taken from the option parameter -ToolKeepInternalEdges
.
Performing Tool Commands
Explode(shape-type)
- shape-type is one of
All|Polylines|Text|Circles|Nurbs|Donuts|DonutsSplit|Arcs
.
This explodes the specified shapes to polygons. If more than one type needs to be exploded, either use All, or repeat the command for the desired types.
CropBounds(x0,y0,x1,y1)
- x0,y0,x1,y1 specifies the crop window. They are expressed in the units specifies using
SetUnits
.
Crops the drawing to the specified size.
-ToolApply=SetUnits(mm);CropBounds(-100,-150,900,100)
MergeZeroWidthPolylines(tolerance)
where tolerance specifies the maximum tolerance distance. The tolerance value is expressed in the units specifies using SetUnits
.
Merges zero-width polylines by performing the following steps on zero-width polylines:
- Split polylines in individual segments at their vertices;
- Snap segment end-points to near segment if within tolerance distance;
- Split segments at common intersections;
- Remove any redundant (duplicate) segments;
- Reassembly (possibly open) polylines from remaining segments.
JoinOpenPolylines
, in order to create closed polygons from the merged polylines
-ToolApply=SetResolution(32);SetUnits(mm);MergeZeroWidthPolylines(120)
JoinOpenPolylines(tolerance)
where tolerance specifies the maximum distance between adjacent polyline end-points. The tolerance value is expressed in the units specifies using SetUnits
.
Joins open polylines, and turns them into polygons.
MergeZeroWidthPolylines
, in order to simplify polylines prior to joining them.
-ToolApply=SetResolution(32);SetUnits(mm);JoinOpenPolylines(120)
-ToolApply=SetResolution(10nm);SetUnits(mm);JoinOpenPolylines(120)
AddWidthToPolylines(width)
Adds with to all zero-width polylines.
EraseZeroWidthPolylines()
Deletes all zero-width polylines.
CloseOpenPolylines()
Closes open polylines, and converts them into polygons, by adding a segement from the last to the first vertex.
RemoveDuplicateShapes()
Removes any duplicate shapes
MergeOverlappingPolygons()
Merges overlapping polygons.
DeEmbedPolygons()
De-embeds polygons. Note that you need to specify Explode(All)
before de-embedding to include other shapes in this operation.
ExtractHoles(mode)
- mode is one of
Holes|FullNesting
.
Extracts holes from polygons onto separate layers. The hole layer will be named after the original layer, with the suffix _neg appended. If such a layer name already exists, _neg1 will be used, where the number is increased as needed.
Modes:
Holes
: Extracts only holes onto separate layersFullNesting
: Extracts polygons nested inside another polygon's hole onto yet another layer. That polygon's holes are then again extracted onto another layer, and so on.
Note that you need to specify Explode(All)
before extracting holes to include other shapes in this operation.
FlattenHierarchy()
Flattens the main cell structure hierarchy. Tools such as DeEmbedPolygons()
only perform on a per-cell basis, so prior flattening may be desired.
SanitizePolygons()
Forces clock-wise orientation for all polygons
DetectArcSegmentsRel(min_vertices,error_margin)
Where
- min_vertices is the minimum number of consecutive vertices that may be converted to an arc segment;
- error_margin defines the relative allowable error, as follows:
An error_margin of 1.0 means that all “n” vertices of the segment are within a distance “s” of the ideal arc, where “s” is maximum distance between an ideal arc and a polygonal arc with “n” vertices. If you set the margin to 2, then that distance “s” may be twice as large (the actual influence is more complex - the algorithm tests many criteria, such as continuous derivation, maximum cord length, standard deviation, …).
A value of 1.0 provides a tight arc fit (or no arc at all, if tight fitting is not possible), whereas large values of “s” (2 or 3) will include more vertices in any given arc with a looser fit. Values above 3 result in large deviations, so use with care. A good compromise is 1.5.
DetectArcSegmentsAbs(min_vertices,max_error)
Where
- min_vertices is the minimum number of consecutive vertices that may be converted to an arc segment;
- max_error defines the absolute allowable error, expressed in the units specifies using
SetUnits
.