mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-06 16:33:15 +01:00
Added wire line command. Code will not generate visible geometry yet.
This commit is contained in:
parent
8b8dbdb399
commit
ead9e7773f
5 changed files with 91 additions and 1 deletions
|
|
@ -0,0 +1 @@
|
||||||
|
<svg version="1.1" viewBox="0.0 0.0 96.0 96.0" fill="none" stroke="none" stroke-linecap="square" stroke-miterlimit="10" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg"><clipPath id="g14470d71bf0_0_144.0"><path d="m0 0l96.0 0l0 96.0l-96.0 0l0 -96.0z" clip-rule="nonzero"/></clipPath><g clip-path="url(#g14470d71bf0_0_144.0)"><path fill="#000000" fill-opacity="0.0" d="m0 0l96.0 0l0 96.0l-96.0 0z" fill-rule="evenodd"/><path fill="#000000" fill-opacity="0.0" d="m12.141732 69.301834l71.71654 -41.133858" fill-rule="evenodd"/><path stroke="#000000" stroke-width="3.0" stroke-linejoin="round" stroke-linecap="butt" d="m12.141732 69.301834l71.71654 -41.133858" fill-rule="evenodd"/><path fill="#00ffff" d="m8.545932 69.23622l0 0c0 -2.4700623 1.9741774 -4.4724426 4.4094486 -4.4724426l0 0c1.1694584 0 2.2910194 0.47120667 3.1179514 1.3099518c0.8269329 0.8387451 1.2914982 1.976326 1.2914982 3.1624908l0 0c0 2.4700623 -1.9741783 4.4724426 -4.4094496 4.4724426l0 0c-2.4352713 0 -4.4094486 -2.0023804 -4.4094486 -4.4724426z" fill-rule="evenodd"/><path fill="#00ffff" d="m79.28871 28.359581l0 0c0 -2.4700623 1.9741821 -4.4724426 4.4094543 -4.4724426l0 0c1.1694565 0 2.2910156 0.47120285 3.1179504 1.309948c0.8269272 0.8387451 1.2914963 1.9763279 1.2914963 3.1624947l0 0c0 2.4700603 -1.9741821 4.472439 -4.4094467 4.472439l0 0c-2.4352722 0 -4.4094543 -2.0023785 -4.4094543 -4.472439z" fill-rule="evenodd"/></g></svg>
|
||||||
|
After Width: | Height: | Size: 1.4 KiB |
|
|
@ -0,0 +1,2 @@
|
||||||
|
# Wire Line
|
||||||
|
This tool allows for creation of a line element by selecting two datum points.
|
||||||
73
modules/workbenches/modeler/features/wireLine/wireLine.ts
Normal file
73
modules/workbenches/modeler/features/wireLine/wireLine.ts
Normal file
|
|
@ -0,0 +1,73 @@
|
||||||
|
import { roundValueForPresentation as r } from 'cad/craft/operationHelper';
|
||||||
|
import { ApplicationContext } from "cad/context";
|
||||||
|
import { EntityKind } from "cad/model/entities";
|
||||||
|
import { OperationDescriptor } from "cad/craft/operationBundle";
|
||||||
|
import icon from "./WireLine.svg";
|
||||||
|
import { MDatum } from 'cad/model/mdatum';
|
||||||
|
|
||||||
|
|
||||||
|
interface WireLineParams {
|
||||||
|
points: MDatum[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export const WireLineOperation: OperationDescriptor<WireLineParams> = {
|
||||||
|
id: 'WIRE_LINE',
|
||||||
|
label: 'Line',
|
||||||
|
icon: icon,
|
||||||
|
info: 'Create Wire Line',
|
||||||
|
path: __dirname,
|
||||||
|
paramsInfo: ({ points }) => `(${r(points)})`,
|
||||||
|
run: (params: WireLineParams, ctx: ApplicationContext) => {
|
||||||
|
const occ = ctx.occService;
|
||||||
|
const oci = occ.commandInterface;
|
||||||
|
console.log(params);
|
||||||
|
oci.line("newLine",
|
||||||
|
params.points[0].csys.origin.x,
|
||||||
|
params.points[0].csys.origin.y,
|
||||||
|
params.points[0].csys.origin.z,
|
||||||
|
|
||||||
|
params.points[1].csys.origin.x,
|
||||||
|
params.points[1].csys.origin.y,
|
||||||
|
params.points[1].csys.origin.z,
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
params.points[0].csys.origin.x,
|
||||||
|
params.points[0].csys.origin.y,
|
||||||
|
params.points[0].csys.origin.z,
|
||||||
|
|
||||||
|
params.points[1].csys.origin.x,
|
||||||
|
params.points[1].csys.origin.y,
|
||||||
|
params.points[1].csys.origin.z, );
|
||||||
|
|
||||||
|
oci.wire("newLineEdge", "newLine");
|
||||||
|
oci.mkface("newLineFace","newLineEdge");
|
||||||
|
oci.prism("newLinePrism", "newLineFace", 0 , 0, 1)
|
||||||
|
|
||||||
|
const created = [occ.io.getShell("newLineFace")];
|
||||||
|
const consumed = [];
|
||||||
|
|
||||||
|
console.log(params.points);
|
||||||
|
|
||||||
|
const returnObject = {
|
||||||
|
created,
|
||||||
|
consumed
|
||||||
|
}
|
||||||
|
return returnObject;
|
||||||
|
|
||||||
|
},
|
||||||
|
form: [
|
||||||
|
{
|
||||||
|
type: 'selection',
|
||||||
|
name: 'points',
|
||||||
|
capture: [EntityKind.DATUM],
|
||||||
|
label: 'points',
|
||||||
|
optional: false,
|
||||||
|
multi: true,
|
||||||
|
defaultValue: {
|
||||||
|
usePreselection: true,
|
||||||
|
preselectionIndex: 0
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"model":
|
||||||
|
{"history":[{"type":"DATUM_CREATE","params":{"x":"75.610","y":"60.041","z":"83.251","rotations":[]}},{"type":"DATUM_CREATE","params":{"x":"53.402","y":"24.307","z":"52.798","rotations":[]}},{"type":"WIRE_LINE","params":{"points":["D:1","D:0"]}}],"expressions":"","assembly":[]},
|
||||||
|
"sketches": [
|
||||||
|
{"id":"F:BASE", "data": {"version":3,"objects":[{"id":"52","type":"Segment","role":null,"stage":0,"data":{"a":{"x":0,"y":0},"b":{"x":13.60211439738466,"y":0}}},{"id":"61","type":"Segment","role":null,"stage":0,"data":{"a":{"x":13.60211439738466,"y":0},"b":{"x":13.60211439738466,"y":9.604682653709794}}},{"id":"70","type":"Segment","role":null,"stage":0,"data":{"a":{"x":13.60211439738466,"y":9.604682653709794},"b":{"x":0,"y":9.604682653709794}}},{"id":"79","type":"Segment","role":null,"stage":0,"data":{"a":{"x":0,"y":9.604682653709794},"b":{"x":0,"y":0}}}],"dimensions":[],"labels":[],"stages":[{"constraints":[{"typeId":"PCoincident","objects":["52:A","boundary/S:0/E:0:B"],"stage":0,"annotations":[]},{"typeId":"PCoincident","objects":["79:B","52:A"],"stage":0,"annotations":[]},{"typeId":"PCoincident","objects":["52:B","61:A"],"stage":0,"annotations":[]},{"typeId":"PCoincident","objects":["61:B","70:A"],"stage":0,"annotations":[]},{"typeId":"PCoincident","objects":["70:B","79:A"],"stage":0,"annotations":[]},{"typeId":"Horizontal","objects":["52"],"constants":{"angle":0},"stage":0,"annotations":[]},{"typeId":"Horizontal","objects":["70"],"constants":{"angle":180},"stage":0,"annotations":[]},{"typeId":"Vertical","objects":["79"],"constants":{"angle":270},"stage":0,"annotations":[]},{"typeId":"Vertical","objects":["61"],"constants":{"angle":90},"stage":0,"annotations":[]}],"generators":[]}],"constants":"","metadata":{"expressionsSignature":"1662874760956"}}}
|
||||||
|
,{"id":"S:1/F:2", "data": {"version":3,"objects":[{"id":"35","type":"Segment","role":null,"stage":0,"data":{"a":{"x":-2.365,"y":2.365},"b":{"x":2.365,"y":2.365}}},{"id":"44","type":"Segment","role":null,"stage":0,"data":{"a":{"x":2.365,"y":2.365},"b":{"x":2.365,"y":-2.365}}},{"id":"53","type":"Segment","role":null,"stage":0,"data":{"a":{"x":2.365,"y":-2.365},"b":{"x":-2.365,"y":-2.365}}},{"id":"62","type":"Segment","role":null,"stage":0,"data":{"a":{"x":-2.365,"y":-2.365},"b":{"x":-2.365,"y":2.365}}},{"id":"71","type":"Segment","role":"construction","stage":0,"data":{"a":{"x":2.365,"y":-2.365},"b":{"x":-2.365,"y":2.365}}}],"dimensions":[],"labels":[],"stages":[{"constraints":[{"typeId":"PCoincident","objects":["62:B","35:A"],"stage":0,"annotations":[]},{"typeId":"PCoincident","objects":["35:B","44:A"],"stage":0,"annotations":[]},{"typeId":"PCoincident","objects":["44:B","53:A"],"stage":0,"annotations":[]},{"typeId":"PCoincident","objects":["53:B","62:A"],"stage":0,"annotations":[]},{"typeId":"Horizontal","objects":["35"],"constants":{"angle":0},"stage":0,"annotations":[]},{"typeId":"Horizontal","objects":["53"],"constants":{"angle":180},"stage":0,"annotations":[]},{"typeId":"Vertical","objects":["62"],"constants":{"angle":90},"stage":0,"annotations":[]},{"typeId":"Vertical","objects":["44"],"constants":{"angle":270},"stage":0,"annotations":[]},{"typeId":"PCoincident","objects":["71:A","44:B"],"stage":0,"annotations":[]},{"typeId":"PCoincident","objects":["71:B","35:A"],"stage":0,"annotations":[]},{"typeId":"PointInMiddle","objects":["ground/ORIGIN","71"],"stage":0,"annotations":[]},{"typeId":"PointOnLine","objects":["ground/ORIGIN","71"],"stage":0,"annotations":[]},{"typeId":"EqualLength","objects":["35","62"],"stage":0,"annotations":[]},{"typeId":"SegmentLength","objects":["35"],"constants":{"length":"4.73"},"stage":0,"annotations":[{"offset":20}]}],"generators":[]}],"constants":"","metadata":{"expressionsSignature":"1662874760956"}}}
|
||||||
|
,{"id":"S:2/SURFACE", "data": {"version":3,"objects":[{"id":"3","type":"Circle","role":null,"stage":0,"data":{"c":{"x":0,"y":0},"r":3.800268700020518}}],"dimensions":[],"labels":[],"stages":[{"constraints":[{"typeId":"PCoincident","objects":["3:C","ground/ORIGIN"],"stage":0,"annotations":[]}],"generators":[]}],"constants":"","metadata":{"expressionsSignature":"1662874760956"}}}
|
||||||
|
,{"id":"F:LID", "data": {"version":3,"objects":[{"id":"57","type":"BezierCurve","role":null,"stage":0,"data":{"cp1":{"x":-22.892986374188528,"y":22.042262464523766},"cp2":{"x":-22.711942223122225,"y":29.615261619747223},"cp3":{"x":-18.61312446708757,"y":33.96476533111906},"cp4":{"x":-18.81753871279943,"y":23.71989819082065}}},{"id":"76","type":"BezierCurve","role":null,"stage":0,"data":{"cp1":{"x":-18.81753871279943,"y":23.71989819082065},"cp2":{"x":-19.081496434786285,"y":10.490821210056968},"cp3":{"x":-23.069196705934502,"y":14.671459897336204},"cp4":{"x":-22.892986374188528,"y":22.042262464523766}}}],"dimensions":[],"labels":[],"stages":[{"constraints":[{"typeId":"PCoincident","objects":["76:2:B","57:1:A"],"stage":0,"annotations":[]},{"typeId":"PCoincident","objects":["76:1:A","57:2:B"],"stage":0,"annotations":[]},{"typeId":"PointOnLine","objects":["76:1:B","57:2"],"stage":0,"annotations":[]},{"typeId":"PointOnLine","objects":["76:2:A","57:1"],"stage":0,"annotations":[]}],"generators":[]}],"constants":"","metadata":{"expressionsSignature":"1662874760956"}}}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -21,6 +21,7 @@ import {PatternRadialOperation} from "./features/patternRadial/patternRadial.ope
|
||||||
import {ImportModelOperation} from "./features/importModel/importModel.operation";
|
import {ImportModelOperation} from "./features/importModel/importModel.operation";
|
||||||
import {DeleteBodyOperation} from "./features/deleteBody/deleteBody.operation";
|
import {DeleteBodyOperation} from "./features/deleteBody/deleteBody.operation";
|
||||||
import {DefeatureRemoveFaceOperation} from "./features/defeatureRemoveFace/defeatureRemoveFace.operation";
|
import {DefeatureRemoveFaceOperation} from "./features/defeatureRemoveFace/defeatureRemoveFace.operation";
|
||||||
|
import { WireLineOperation } from "./features/wireLine/wireLine";
|
||||||
//imports of action type commands
|
//imports of action type commands
|
||||||
import {GiCubes} from "react-icons/gi";
|
import {GiCubes} from "react-icons/gi";
|
||||||
|
|
||||||
|
|
@ -49,6 +50,7 @@ export const ModelerWorkspace: WorkbenchConfig = {
|
||||||
ImportModelOperation,
|
ImportModelOperation,
|
||||||
DeleteBodyOperation,
|
DeleteBodyOperation,
|
||||||
DefeatureRemoveFaceOperation,
|
DefeatureRemoveFaceOperation,
|
||||||
|
WireLineOperation,
|
||||||
],
|
],
|
||||||
actions: [
|
actions: [
|
||||||
// GetVolume,
|
// GetVolume,
|
||||||
|
|
@ -67,7 +69,9 @@ export const ModelerWorkspace: WorkbenchConfig = {
|
||||||
|
|
||||||
"CYLINDER", "BOX", "CONE", "SPHERE", "TORUS", "-",
|
"CYLINDER", "BOX", "CONE", "SPHERE", "TORUS", "-",
|
||||||
|
|
||||||
"HOLE_TOOL", "-", 'GET_VOLUME', "IMPORT_MODEL", "DELETE_BODY",
|
"HOLE_TOOL", "-", 'GET_VOLUME', "IMPORT_MODEL", "DELETE_BODY", "-",
|
||||||
|
|
||||||
|
"WIRE_LINE"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
icon: GiCubes
|
icon: GiCubes
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue