- Started Solvespace implementation solver
This commit is contained in:
25
drawing_modules/solvespace_example.py
Normal file
25
drawing_modules/solvespace_example.py
Normal file
@@ -0,0 +1,25 @@
|
||||
from python_solvespace import SolverSystem, ResultFlag
|
||||
|
||||
def solve_constraint(self):
|
||||
solv = SolverSystem()
|
||||
wp = solv.create_2d_base() # Workplane (Entity)
|
||||
p0 = solv.add_point_2d(0, 0, wp) # Entity
|
||||
solv.dragged(p0, wp) # Make a constraint with the entity
|
||||
...
|
||||
line0 = solv.add_line_2d(p0, p1, wp) # Create entity with others
|
||||
...
|
||||
line1 = solv.add_line_2d(p0, p3, wp)
|
||||
solv.angle(line0, line1, 45, wp) # Constrain two entities
|
||||
line1 = solv.entity(-1) # Entity handle can be re-generated and negatively indexed
|
||||
...
|
||||
if solv.solve() == ResultFlag.OKAY:
|
||||
# Get the result (unpack from the entity or parameters)
|
||||
# x and y are actually float type
|
||||
dof = solv.dof()
|
||||
x, y = solv.params(p2.params)
|
||||
...
|
||||
else:
|
||||
# Error!
|
||||
# Get the list of all constraints
|
||||
failures = solv.failures()
|
||||
...
|
||||
Reference in New Issue
Block a user