What's new

Accessing lines, arcs, etc in a sketch

R-man

Senior Member
A couple of questions:

From a script can I list all lines (for example) in a sketch, and get information about them?

Can I name a line when I add it to a sketch and then refer to it by name to get info?
 

albie0803

Alibre Super User
Yes you can. You can do something like this

Code:
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)
 

R-man

Senior Member
How about getting information about lines etc. For example is there something like lineLen = line3.length ?
 

NateLiquidGravity

Alibre Super User
Yes, AlibreScript has an ability like that. I suggest checking out the quick start, reference/help files, and examples found in the AlibreScript menu.
 

R-man

Senior Member
Thanks Nate - I've never bothered much with the reference because the terminology is alien to me, but after an hour or so of making the effort I'm finding my way around. Good advice!
 
Top