Sketcher Angle Constraints

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Sketcher Angle Constraints

Post by microelly2 »

I have testet all possibilities of blue angle constraints
and I get some values greater than 360°
Is this a bug?

having an angle between -180° and 180° would be the best.
bp_473.png
bp_473.png (29.22 KiB) Viewed 1823 times
testcase:

Code: Select all


import numpy as np

App.newDocument("Unnamed")
App.setActiveDocument("Unnamed")
App.ActiveDocument=App.getDocument("Unnamed")
Gui.ActiveDocument=Gui.getDocument("Unnamed")
sk=App.activeDocument().addObject('Sketcher::SketchObject','Sketch')


sk.addGeometry(Part.LineSegment(App.Vector(0.000000,0.000000,0),App.Vector(50,50,0)),False)
sk.addConstraint(Sketcher.Constraint('Coincident',0,1,-1,1)) 
App.ActiveDocument.recompute()
sk.addConstraint(Sketcher.Constraint('Distance',0,100)) 
App.ActiveDocument.recompute()



d=sk.addConstraint(Sketcher.Constraint('Angle',-1,1,0,1,np.pi/6)) 
sk.toggleDriving(d) 
d=sk.addConstraint(Sketcher.Constraint('Angle',-1,2,0,1,np.pi/6)) 
sk.toggleDriving(d) 
d=sk.addConstraint(Sketcher.Constraint('Angle',0,1,-1,1,np.pi/6)) 
sk.toggleDriving(d) 
d=sk.addConstraint(Sketcher.Constraint('Angle',0,1,-1,2,np.pi/6)) 
sk.toggleDriving(d) 

d=sk.addConstraint(Sketcher.Constraint('Angle',-2,1,0,1,np.pi/6)) 
sk.toggleDriving(d) 
d=sk.addConstraint(Sketcher.Constraint('Angle',-2,2,0,1,np.pi/6)) 
sk.toggleDriving(d) 
d=sk.addConstraint(Sketcher.Constraint('Angle',0,1,-2,1,np.pi/6)) 
sk.toggleDriving(d) 
d=sk.addConstraint(Sketcher.Constraint('Angle',0,1,-2,2,np.pi/6)) 
# sk.toggleDriving(d) 
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Sketcher Angle Constraints

Post by DeepSOIC »

Hi!
Blue constraints are powered by the same code as red constraints, so values 30 and 30+n*360 have the same meaning.
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Sketcher Angle Constraints

Post by microelly2 »

DeepSOIC wrote:Hi!
Blue constraints are powered by the same code as red constraints, so values 30 and 30+n*360 have the same meaning.
Thats true, but if I use the angle to configure another shape (example a helix there is a difference between 30 and 390)
At the moment I cannot use expressions like

int(Constraint.MyAngle/pi*180)%360
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Sketcher Angle Constraints

Post by abdullah »

microelly2 wrote:I have testet all possibilities of blue angle constraints
and I get some values greater than 360°
Is this a bug?

having an angle between -180° and 180° would be the best.
https://github.com/FreeCAD/FreeCAD/pull/708
driving_angles1.png
driving_angles1.png (27.89 KiB) Viewed 1750 times
Post Reply