-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: loft feature * feat: partstudio loft interface * feat: add test for loft * lint * fix: bad plane selection
- Loading branch information
1 parent
747d7c4
commit c196d45
Showing
6 changed files
with
158 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from onpy.features.extrude import Extrude | ||
from onpy.features.sketch import Sketch | ||
from onpy.features.planes import Plane, OffsetPlane, DefaultPlane | ||
from onpy.features.loft import Loft |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
"""OnShape extrusion feature""" | ||
|
||
from typing import TYPE_CHECKING, override | ||
from onpy.api.model import Feature, FeatureAddResponse | ||
from onpy.features.base import Feature, Extrudable | ||
import onpy.api.model as model | ||
from onpy.util.misc import unwrap | ||
from onpy.features.query.list import QueryList | ||
|
||
if TYPE_CHECKING: | ||
from onpy.elements.partstudio import PartStudio | ||
|
||
|
||
class Loft(Feature): | ||
"""Interface to lofting between two 2D profiles""" | ||
|
||
def __init__( | ||
self, | ||
partstudio: "PartStudio", | ||
start_face: QueryList, | ||
end_face: QueryList, | ||
name: str = "Loft", | ||
) -> None: | ||
|
||
self._partstudio = partstudio | ||
self._id: str | None = None | ||
self._name = name | ||
|
||
self.start_face = start_face | ||
self.end_face = end_face | ||
|
||
self._upload_feature() | ||
|
||
@property | ||
@override | ||
def partstudio(self) -> "PartStudio": | ||
return self._partstudio | ||
|
||
@property | ||
@override | ||
def id(self) -> str: | ||
return unwrap(self._id, "Loft feature id unbound") | ||
|
||
@property | ||
@override | ||
def name(self) -> str: | ||
return self._name | ||
|
||
@property | ||
@override | ||
def entities(self): | ||
raise NotImplementedError() | ||
|
||
@override | ||
def _load_response(self, response: FeatureAddResponse) -> None: | ||
self._id = response.feature.featureId | ||
|
||
@override | ||
def _to_model(self) -> model.Loft: | ||
|
||
return model.Loft( | ||
name=self.name, | ||
suppressed=False, | ||
parameters=[ | ||
{ | ||
"btType": "BTMParameterEnum-145", | ||
"namespace": "", | ||
"enumName": "ToolBodyType", | ||
"value": "SOLID", | ||
"parameterId": "bodyType", | ||
}, | ||
{ | ||
"btType": "BTMParameterEnum-145", | ||
"namespace": "", | ||
"enumName": "NewBodyOperationType", | ||
"value": "NEW", | ||
"parameterId": "operationType", | ||
}, | ||
{ | ||
"btType": "BTMParameterEnum-145", | ||
"namespace": "", | ||
"enumName": "NewSurfaceOperationType", | ||
"value": "NEW", | ||
"parameterId": "surfaceOperationType", | ||
}, | ||
{ | ||
"btType": "BTMParameterArray-2025", | ||
"items": [ | ||
{ | ||
"btType": "BTMArrayParameterItem-1843", | ||
"parameters": [ | ||
{ | ||
"btType": "BTMParameterQueryList-148", | ||
"queries": [ | ||
{ | ||
"btType": "BTMIndividualQuery-138", | ||
"deterministicIds": [ | ||
e.transient_id | ||
for e in self.start_face._available | ||
], | ||
} | ||
], | ||
"parameterId": "sheetProfileEntities", | ||
} | ||
], | ||
}, | ||
{ | ||
"btType": "BTMArrayParameterItem-1843", | ||
"parameters": [ | ||
{ | ||
"btType": "BTMParameterQueryList-148", | ||
"queries": [ | ||
{ | ||
"btType": "BTMIndividualQuery-138", | ||
"deterministicIds": [ | ||
e.transient_id | ||
for e in self.end_face._available | ||
], | ||
} | ||
], | ||
"parameterId": "sheetProfileEntities", | ||
} | ||
], | ||
}, | ||
], | ||
"parameterId": "sheetProfilesArray", | ||
}, | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters