What's new

Dimensions

idslk

Alibre Super User
Hello Simon,
this is a question in the AlibreScript Section of the forum...;-)
Regards
Stefan
 

albie0803

Alibre Super User
So this has never been answered and I'm sure you still can't and it really needs to be implemented.

Sketch.AddDimension(Line1, Line2) which returns a distance if the lines are parallel and an angle if they are not.

X and Y axes need to be added to sketches so that lines can be dimensioned from an axis - Sketch.AddDimension(XAxis, Line1) - returning the same values as above.

My shaft building script imports points from excel, uses them to draw lines, dimensions all the horizontal lines but I can't programmatically set the radius distance of each line before revolving the sketch. That is a manual step I have to open up the sketch to do. AND IT'S ANNOYING.

Can this be added to V22 please or at least get an answer if it is even possible.

My (uneducated) assumption is that if I can do it normally, I should be able to do it programmatically.
 

DavidJ

Administrator
Staff member
If you add a dimension manually between axis and line in a sketch, you'll note that AD automatically adds a reference line in the sketch to coincide with the axis.

I suspect you'll have to do the same thing in your script, Add reference line on the axis, constrain it fixed (?), then add dimension from reference line to your line.

That makes sense, the axes don't 'exist' as features in the sketch (which may or may not lie in a plane that contains the axis in question), they can be projected from the workspace into the sketch.
 

albie0803

Alibre Super User
I suspect you'll have to do the same thing in your script, Add reference line on the axis, constrain it fixed (?), then add dimension from reference line to your line.
I could live with that. The logic makes sense.
Code:
XLine = Sketch.AddLine([0,0],[50,0], True)
Sketch.AddConstraint([XLine.Start, Sketch.Origin],Sketch.Constraints.Coincident)
Sketch.AddConstraint([XLine],Sketch.Constraints.Vertical)
YLine = Sketch.AddLine([0,0],[0,50], True)
Sketch.AddConstraint([YLine.Start, Sketch.Origin],Sketch.Constraints.Coincident)
Sketch.AddConstraint([YLine],Sketch.Constraints.Vertical)
So I just need Sketch.AddDimension(Line1, Line2) which returns a distance if the lines are parallel and an angle if they are not.
 

NateLiquidGravity

Alibre Super User
Does anyone else find that the sketch solver doesn't work with things added by the Alibre Script/API? Meaning it doesn't move objects to make the constraints valid like it does when manually assigning them.
 

simonb65

Alibre Super User
Does anyone else find that the sketch solver doesn't work with things added by the Alibre Script/API? Meaning it doesn't move objects to make the constraints valid like it does when manually assigning them.
Do you mean like sketch analysis healing, etc? ... which does work.

If you mean visibly seeing the constraint (or dim) move the sketch, I haven't tried that but does the UI need a refresh or a regenerate on the model perhaps.
 

NateLiquidGravity

Alibre Super User
I'm looking into it further but there are definitely bugs. At the very least - using Fixed constraint on some things prevents some other things from being constrained in a sketch - even manually.
 

NateLiquidGravity

Alibre Super User
Try this example.
Code:
Units.Current = UnitTypes.Inches
prt = CurrentPart()
sk = prt.AddSketch('Test', prt.XYPlane)

Point1 = sk.AddPoint(1,1)
Point2 = sk.AddPoint(5,2)
Point3 = sk.AddPoint(4,3)
print(sk.AddConstraint(Point1,Sketch.Constraints.Fix))
#print(sk.AddConstraint(Point2,Sketch.Constraints.Fix))

sk.AddDimension(Point1, Point2)
sk.AddDimension(Point2, Point3)
sk.AddDimension(Point3, Point1)

Line1 = sk.AddLine(0,-1,5,-1,False)
Line2 = sk.AddLine(0,-2,5,-2,False)
Line3 = sk.AddLine(0,-3,5,-3,False)

print(sk.AddConstraint([Point1, Line1],Sketch.Constraints.Coincident))
print(sk.AddConstraint([Point2, Line1],Sketch.Constraints.Coincident))
print(sk.AddConstraint([Point2, Line2],Sketch.Constraints.Coincident))
print(sk.AddConstraint([Point3, Line2],Sketch.Constraints.Coincident))
print(sk.AddConstraint([Point3, Line3],Sketch.Constraints.Coincident))
print(sk.AddConstraint([Point1, Line3],Sketch.Constraints.Coincident))
Notice all the constraints resulted in True. The lines ends are intentionally not stuck to the sketch points. You can spin the "triangle" around Point1 because only one sketch point was fixed.

Now uncomment this line to fix one of the other sketch points and run again.
Code:
#print(sk.AddConstraint(Point2,Sketch.Constraints.Fix))
Notice how all the constraints after that one resulted in False.
 

NateLiquidGravity

Alibre Super User
Another problem is nodes (line end points, sketch points) automatically constrain when they overlap while moving programmatically. You can avoid this when you can see it as a user on a screen but not programmatically. We need the ability to turn that off/on. Notice how one end point of a line is stuck to one of the sketch points - but nobody told it to do that.
 

NateLiquidGravity

Alibre Super User
Another problem is some things can't be dimensioned easily.
For example a sketch point at a distance perpendicular from a line.
The vertical distance from sketch point to sketch point.
The horizontal distance from sketch point to sketch point.
 

NateLiquidGravity

Alibre Super User
We need this ability!
I certainly think so. I created support tickets for these issues.

Did you try and notice the problems I described with that script?
I find that once the sketch's constraints are messed up programmatically that you can't even add constraints manually to that sketch.
 
Top