pressButton and releaseButton for the freeCad Polylinearc

The mousemove arcs and CW CCW seem to be working out ok. Now comes the fun stuff: To see if I can get the Arc to actually draw out properly as a real freecad object in the pressButton and releaseButton  event.   Some of the initial code is basically recycled from draw arc object which was combined into the polyline.  I had some initial seg faults with obvious errors, which I managed to clean up.  Now there is the first set of things to work on:

 

 

 

 

 

 

 

 

 

 

 

I had a bunch of silly errors going on here.  At this point it’s basically copy paste incompatbilities of bringing DrawSketchHandlerArc functionalility into
std::vector<Base::Vector2D> EditCurve;   Isn’t getting cleared out properly.  That construct is both in the draw arc and DrawSketchHandlerLineSet.  Fixed  and a few other things..

Ok. Got the Easy errors out of the way and I’m left with this.

 

 

 

 

 

The error that I’m seeing in this is the circle not curving the correct way when the arc is drawn clockwise.
The offending culprit is here:

else{//We’re dealing with an Arc
Gui::Command::openCommand(“Add sketch arc”);
Gui::Command::doCommand(Gui::Command::Doc,
“App.ActiveDocument.%s.addGeometry(Part.ArcOfCircle”
“(Part.Circle(App.Vector(%f,%f,0),App.Vector(0,0,1),%f),”
“%f,%f))”,
sketchgui->getObject()->getNameInDocument(),
CenterPoint.fX, CenterPoint.fY, radiusLength,
startAngle, endAngle); //arcAngle > 0 ? 0 : 1);

}

At this point, I haven’t do on the openCommand and doCommand stuff.  I’m hoping this is not going to turn into a mutli-week adventure.  I’m thinking one think I might try before digging into to that is to figure out how to add a tangent constraint as see if that fixes everything. (Worth a try).
4-22-12.
Having slept on this a thought occurs to me.

All kinds of errors but I’m just focusing on one at the moment.     At this point, if I draw a polyline arc which results in a clockwise arc being generated the arc is drawn counter clockwise.
Now if I draw 2 line segments separately and then connect them through the DrawSketchHandlerFillet utility is constructs just fine.

 

 

 

 

 

So I’m thinking that I need to digest DrawSketchHandlerFillet a bit.  When I understand that, I should have a handle on how to fix my clockwise arc issue.

 

 

 

 

 

Hmm. it looks like everything runs through the python inter-phase which wraps some c++ code.

Looking at the pertinent python lines:

  • App.ActiveDocument.Sketch.addGeometry(Part.ArcOfCircle(Part.Circle(App.Vector(-39.882378,82.379395,0),App.Vector(0,0,1),64.732491),-2.201594,-1.347593))
  • App.ActiveDocument.Sketch.fillet(3,4,App.Vector(-153.321411,28.704008,0),App.Vector(-99.413879,-8.751223,0),97.736731)

The thing is that App.ActiveDocument.Sketch.fillet needs a vector which I don’t have yet and App.ActiveDocument.Sketch.addGeometry(Part.ArcOfCircle doesn’t seem to work for me.

What’s frustrating is that my c++ IDE won’t let me step into the python stuff.
ArcOfCircle of circle appears here:http://free-cad.sourceforge.net/SrcDocu/da/d6b/classPart_1_1ArcOfCirclePy.html
http://free-cad.sourceforge.net/SrcDocu/de/d18/ArcOfCirclePyImp_8cpp.html

Lets see if I can find anything on this fillet stuff.. Not not sure if this is it:
http://free-cad.sourceforge.net/SrcDocu/dc/d77/classSketcher_1_1SketchObjectPy.html#acb8afeb9c0f5a6be444dad29ed74109b
I think I need to think on this a bit, and do something else for a little while… (Like mow the lawn).

4-23-12

The suggestion came to reverse the start and finish on drawing out a clockwise arc was req’d
Logic that could be adapted is this:

 else {
EditCurve.resize(30);
float angle1 = atan2(onSketchPos.fY – CenterPoint.fY,
onSketchPos.fX – CenterPoint.fX) – startAngle;
float angle2 = angle1 + (angle1 < 0. ? 2 : -2) * M_PI ;

arcAngle = abs(angle1-arcAngle) < abs(angle2-arcAngle) ? angle1 : angle2;
if (arcAngle > 0)
endAngle = startAngle + arcAngle;
else {
endAngle = startAngle;
startAngle += arcAngle;
}

sketchgui->drawEdit(EditCurve);
applyCursor();
Mode = STATUS_End;
}

I tried to incorporate that code just before drawing the arc and I seem to be getting a few issues that need to be worked out.

4-25-12 Update..
Found a bunch of issues in the releasebutton event.

Tried incorporation above code in mouse move… Didn’t work as well as what I had… (Behavior was irratic.) Since What I had might have been a little more complex, it worked.  Went back to that.

Starting to get into the constraints.  This python wrapper thing is somewhat of a nuisance since I can’t step into that while debugging in the IDE. ;(
I code myself into a seg fault condition… Need to look at what baseline code was to figure out where things went south.

http://free-cad.sourceforge.net/SrcDocu/da/deb/CommandCreateGeo_8cpp_source.html#l00551

Well I moved the error around, but still no joy.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *