Removes JSON from the KCL object model. Closes https://github.com/KittyCAD/modeling-app/issues/1130 -- it was filed on Nov 27 last year. Hopefully I close it before its one year anniversary. Changes: - Removed the UserVal variant from `enum KclValue`. That variant held JSON data. - Replaced it with several new variants like Number, String, Array (of KCL values), Object (where keys are String and values are KCL values) - Added a dedicated Sketch variant to KclValue. We used to have a variant like this, but I removed it as an experimental approach to fix this issue. Eventually I decided to undo it and use the approach of this PR instead. - Removed the `impl_from_arg_via_json` macro, which implemented conversion from KclValue to Rust types by matching the KclValue to its UserVal variant, grabbing the JSON, then deserializing that into the desired Rust type. - Instead, replaced it with manual conversion from KclValue to Rust types, using some convenience macros like `field!`
132 KiB
132 KiB
title, excerpt, layout
title | excerpt | layout |
---|---|---|
polygon | Create a regular polygon with the specified number of sides that is either inscribed or circumscribed around a circle of the specified radius. | manual |
Create a regular polygon with the specified number of sides that is either inscribed or circumscribed around a circle of the specified radius.
polygon(data: PolygonData, sketch_surface_or_group: SketchOrSurface, tag?: TagDeclarator) -> Sketch
Arguments
Name | Type | Description | Required |
---|---|---|---|
data |
PolygonData |
Data for drawing a polygon | Yes |
sketch_surface_or_group |
SketchOrSurface |
A sketch surface or a sketch. | Yes |
tag |
TagDeclarator |
No |
Returns
Sketch
- A sketch is a collection of paths.
Examples
// Create a regular hexagon inscribed in a circle of radius 10
hex = startSketchOn('XY')
|> polygon({
radius: 10,
numSides: 6,
center: [0, 0],
inscribed: true
}, %)
example = extrude(5, hex)
// Create a square circumscribed around a circle of radius 5
square = startSketchOn('XY')
|> polygon({
radius: 5.0,
numSides: 4,
center: [10, 10],
inscribed: false
}, %)
example = extrude(5, square)