Sketcher Angle Constraints

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
User avatar
microelly2
Posts: 4690
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Sketcher Angle Constraints

Postby microelly2 » Fri Apr 21, 2017 2:16 pm

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 995 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
Posts: 7762
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: Sketcher Angle Constraints

Postby DeepSOIC » Sat Apr 22, 2017 1:49 pm

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
Posts: 4690
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Sketcher Angle Constraints

Postby microelly2 » Sat Apr 22, 2017 2:15 pm

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
Posts: 3530
Joined: Sun May 04, 2014 3:16 pm

Re: Sketcher Angle Constraints

Postby abdullah » Sun Apr 23, 2017 4:04 am

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 922 times