SGofCPLcommand

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Parametric Design
Introduced first in SolidGeometry 4.3, Creation date: 2018-10-25, Last change: 2025-09-14

Simple commandline based 2.5 solid modeler for the use of a caliper

Description

First a Contour is designed; afterwards the contour is extruded; and set below the already designed existing solid; ATTENTION IF YOU MELT THE PARTS AFTERWARDS AVOID edges with same planes

SGofCPLcommands supports the following commands, separated by commas:
See publishable tutorial VLFL_EXP45.m

=== CPL shape commands =================================
b x-size y-size [d] => Box as rectangle or displace trapaze
bs x-size y-size [dx dy] => Box shift as rectangle with shiftx and shift y
c diameter diameter edges => Cylinder or ellipse as polygon
cs phi r-outer r-inner offset => Cylinder segment with angle
co r-outer length r-inner => Cylinder oval segment with optional holes
d diameter x-coord y-coord n-faces => Drilling hole at x/y with n edges
g diameter teeth-nr turn => Gear that it turned (f.i. 0.5 teeth)
ms diameter-1 diameter-2 => Motor shaft contour

=== CPL manipulation commands =================================
move x-coord y-coord => Move the CPL relatively
cp x-coord y-coord => Center point change
ch distance radius => Convex hull in distance with optional radius
dupc x-copies y copies distance => Duplicates contour in as x y pattern
dupr radius number offset => Duplicates contour radial in n copies
rad radius => Radial edges (+r) or cuts (-r) at each corner
rot degree x y => Rotate a contour ccw by degree on centerpoint x y, default is center of CPL
mirr x1 y1 x2 y2 => mirror CPL at straigth line through p1 p2
fitt char => create fitting buffer 'c', 't', 'i' for all holes in CPL

=== CPL stack commands =================================
enter => current CPL is shifted to the stack
dup => current CPL is duplicated to the stack
swap => current CPL is swaped with CPL on stack
+/add => current CPL is added to stack CPL
-/sub => current CPL is substracted from stack CPL
rem => stack CPL ist substracted from current CPL
&/isec => current CPL is intersected with stack CPL
hs height => stack connection using height

=== CPL to solid commands =================================
h height z-displacement => Height of the extruded solid
hc height z-displacement => Height of extrusion with smoothed edges
r angle pitch => Extrusion by rotation (degree) and optional pitch

=== SG element commands =================================
scr mm length diameter => Screw/Cutter/Nut threat of diameter and length
sph diameter end-angle => Sphere
text string size-x size-z => Text string without space

=== SG manipulation commands =================================
move x-coord y-coord => Move the solid relatively
cham rar upper-dist lower-dist => Chamfer the edges of a 2.5 solid
rotx degree => rotate around the x-axis
roty degree => rotate around the y-axis
rotz degree => rotate around the z-axis
mirr x-degree y-degree z-displacement => mirror at the xy plane rotated around x and y-axis shifted in z
grow offset => Grow/shrink the current solid with an offset
melt => Boolean addition of all solid elements
textstamp string => Add a string to the largest surface
dupr number => Duplicates solids radial in n copies
dups nx ny nz d => Duplicates solid spatial in x y z with distance d
dupg nx ny nz d => Duplicates solid on a grid in x y z with distance d
hollow wall => Creates a hollow solid
shell wall distance => Creates a shell for the solid
cutz z1 z2 => Cuts the solid at z1 and z2

=== SG save and restore commands =================================
save name => saves the solid into name.SG
load name => loads a solid from name.SG
write name => saves the solid into File name.STL
read name => reads the solid from File name.STL
mag fact => magnifies the current solid
col color => colors the faces of the current solid

=== SG stack commands =================================
enter => current SG is shifted to the stack
dup => current SG is duplicated to the stack
swap => current SG is swaped with SG on stack
clear nr => Clear stack content 1..n
+/add => current SG is added to stack SG
-/sub => current SG is substracted from stack SG
rem => stack SG is substracted from current SG
&/isec => current SG is intersected with stack SG
rel command parameter => current SG is move relatively to stack

=== Frame commands =================================
fset name ident rotation feature => attach a frame to the current SG
falign Stack-Frame SG-Frame degree => align current SG-frame with stack frame and rotate

=== Macro commands =================================
$cmd: : => Define macro using $1 $2 $3 $4 as parameters
$cmd $1 $2 $3 $4 => Use macro as command with $1 $2 $3 $4 as parameters


Try: SGofCPLcommand('g 3 22, h 5, c 5, h 20, roty -90, move 10 10')
Try: SGofCPLcommand('$cob: co $1 $2 $3, h $3, fset B 1 0 R1, fset F 2 0 R2:, $cob 10 50 5, dup, falign F B 45')
Try: SGofCPLcommand('b 30 10, h 10, enter, $hole: c 3, h 10, rotx 90,move $1 $2 $3 :,$hole 10 5 5,-,enter, $hole 0 5 5,-,enter, $hole -10 5 5,-') % by Kei Aoyagi


2018-11-21 Tim Lueth (implementation) and Yilun Sun (requests) discussed the boolean RPN (reverse Polish Notation / Forth) concept using stacks


See Also: , SGofCPLz , SGsurfacemeltbool , SGsurfacemeltbool

Example Illustration

 missing image of SGofCPLcommand(cstr,blines,t,gap1,gap2,gap3)

Syntax

[SG,CPLO,warn]=SGofCPLcommand(cstr,[blines,t,gap1,gap2,gap3])

Input Parameter

cstr: CPL command string, use '?' for info
blines:
t:
gap1:
gap2:
gap3:

Output Parameter

SG: solid Geometry
CPLO:
warn:

Examples


SGofCPLcommand('g 4 21, h 4'); % Gear with diameter 4mm, 21 teeth, height 4 mm
SGofCPLcommand('g 4 21, h 4, c 3, h 1, move 5 0, b 40 10 ,h 2,b 25 10 , h 20')
SGofCPLcommand('g 4 21, h 4, c 3, h 1, move 5 0, b 40 10 ,d 2.5 -15 0, d 2.5 +15 0, h 2,b 25 10 , h 20')
SGofCPLcommand('g 4 21, h 4, c 3, h 1, move 5 0, b 15 8, h 4, b 40 10 ,d 2.5 -15 0, d 2.5 +15 0, h 2,b 25 10 , h 20')
SGofCPLcommand('g 4 21, h 4, c 3, h 1, move 5 0, b 15 8, hc 4, b 40 10 ,d 2.5 -15 0, d 2.5 +15 0, hc 2,b 25 10 , hc 20')
SGofCPLcommand('g 5 10, enter, b 10 30 10')
SGofCPLcommand('g 5 10, enter, b 10 30 10')
SGofCPLcommand('g 5 10, enter, b 10 30 10, xor, h 4')




Copyright 2018-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth

Last html export of this page out of FM database by TL: 2025-09-21