MyPart = Part('My Part')
MySketch = MyPart.AddSketch('SomeName', MyPart.XYPlane)
p1 = [0, 0]
p2 = [0, 10]
p3 = [10, 10]
p4 = [10, 5]
line1 = MySketch.AddLine(p1, p2, False)
line2 = MySketch.AddLine(p2, p3, False)
line3 = MySketch.AddLine(p3, p4, False)
MySketch.AddDimension(line1.Start, line1.End)
MySketch.AddDimension(line2.Start, line2.End)
MySketch.AddDimension(line3.Start, line3.End)
result = MySketch.AddConstraint([line1],Sketch.Constraints.Vertical)
print(result)
result = MySketch.AddConstraint([line2],Sketch.Constraints.Horizontal)
print(result)
result = MySketch.AddConstraint([line3],Sketch.Constraints.Vertical)
print(result)
and i tried and tried and triedNote: AddDimension and AddConstraint are 2019 beta features
I did that originally and thought it may be clearer to others separate.You can eliminate a line with:
Code:result = MySketch.AddConstraint([line1, line3],Sketch.Constraints.Vertical) print(result)
Andy
You need to let the dust settle on my posts more.
and i tried and tried and tried
if it is still valid, trying to assign a line to a variable won't be successful...Some things to be cleared up:
- Some functions do not have a return (void) so there is no need to assign it to a variable. For example AddCircle and AddPolygon have no return, that's why the console says "added Circle: None":
cp = CurrentPart()
mysketch = cp.AddSketch('MySketch', cp.XYPlane)
lines = []
p = [[10,13],[24,10],[18,26],[44,36]]
#Fill p with values from whereever, using some analogous like p.append(excelcells) or so
for i in range(0,len(p),2):
print p[i]
lines.append(mysketch.AddLine(p[i], p[i+1], False))
print lines
print 'done'
Some things to be cleared up:
- Some functions do not have a return (void) so there is no need to assign it to a variable. For example AddCircle and AddPolygon have no return, that's why the console says "added Circle: None":
From my post in the Beta forum:That's a question for Alibre not me. Unless I am misunderstanding something?
Andy
◆ Constraints
enum Constraints
strong
Supported sketch constraints
print(dir(Sketch.Constraints))
From my post in the Beta forum:
The (AlibreScript) documentation however does not list the options and only says:
print(dir(Sketch.Constraints))
Profile.AddConstraint([Line.Start, Profile.Origin],Sketch.Constraints.Concentric)
The new beta does list available options in the reference. No need to print that anymore.So Concentric is not an option so
is not possible. I would have thought that being able to anchor a line end or circle centre to the origin would have been one of the first thing to be done. Oh well.Code:Profile.AddConstraint([Line.Start, Profile.Origin],Sketch.Constraints.Concentric)