questions on arc direction (sense) in vba macro

It seems I have come across a problem that is proving somewhat difficult to solve.

I have an extrusion, think of a simple rectangle with some round holes cut or some round extrusions added to the profile. so it's like a swiss cheese, a hole in the middle, a "half-hole" on one edge, a bump on another etc... I don't know if it's even possible to post pictures, if it is then I'll post a snapshot of what I'm talking about.

To my problem

I have created some vba code to go through a selected face, go through all CoEdges and do some custom stuff. The problem arises with arcs. I have x,y,z, start x,y,z, end x,y,z, radius, everything but the direction of the arc is giving me gray hairs.

When I go through all edges of the face each next edge is counter-clockwise from the previous one.

Now my understanding of edge and curve "sense" is it tells you if the edge has been drawn clockwise or counter-clockwise. Which is fine. Exactly what I need in order to figure out whether the arc I'm currently dealing with is an "insie" or an "outside" (i.e. a cut in the side of my profile or a bump along it's edge)

But it's not so simple as I get funny results with one of the arcs. two arcs are fine but the third is allways "wrong way round".

Can someone enlighten me with the use of "sense"?

Thanks!

Pele

Reply to
pele
Loading thread data ...

here are the pictures of what my shape looks like and what I'm getting to help you visualise everything. red edges are sense=true and blue edges are sense=false. green dot start of edge, red dot end of edge (notice that on blue edges order of start/end dots is reversed)

formatting link

Reply to
pele

go to "view slideshow" to get the correct order of images and to see what I'm seeing when I run my macro. I'm having problems with the second arc, the one that appears to be sense=true but is actually clockwise (i.e. it cuts into the profile) and from what I've learned about sense it should be false (and it should be highlighted blue by my macro) but it's not! What gives?

Reply to
pele

Looking at it...

Reply to
That70sTick

Which particular API calls are you using? Your description of output ("x,y,z, start x,y,z, end x,y,z, radius") does not match anything I am finding in API help.

Reply to
That70sTick

heh ok sorry that was just a simplification of my calls.

here's my function that "reckognises" a circle or an arc and if it's an arc calls drawArc (another function of mine). It's the stuff immediately before the call to drawArc that's confusing me. on my second arc (the one on the right-most edge of my part that cuts into it) I get the wrong sense and consequently wrong direction which then results in that "insie" becoming an "outsie".

Sub doCircle(partFace As Variant, coEdgeObj As SldWorks.CoEdge, msg As Variant, out As GCode) Dim CircleParams As Variant Dim CurveParameters As Variant 'Dim edgeObj As SldWorks.Edge

Set edgeObj = coEdgeObj.GetEdge

CircleParams = edgeObj.GetCurve.CircleParams() CurveParameters = edgeObj.GetCurveParams2

x = CircleParams(0) y = CircleParams(1) z = CircleParams(2) r = CircleParams(6)

msg = "Center point:" + Chr(10) msg = msg + "X:" + format(x) + ",Y:" + format(y) + ",Z:" + format(z) + Chr(10) msg = msg + "Radius:" + format(r) + Chr(10) If CurveParameters(0) = CurveParameters(3) And CurveParameters(1) = CurveParameters(4) Then Title = "Circle Info" out.drawCircle x, y, z, r Else Title = "Arc Info"

Dim startX, endX, startY, endY As Double Dim sense As Boolean

sense = edgeObj.EdgeInFaceSense(partFace)

startX = CurveParameters(0) startY = CurveParameters(1) startZ = CurveParameters(2) endX = CurveParameters(3) endY = CurveParameters(4) endZ = CurveParameters(5)

msg = msg + "Start point:" + Chr(10) msg = msg + "X:" & format(startX) & ",Y:" & format(startY) & Chr(10) msg = msg + "End point:" + Chr(10) msg = msg + "X:" & format(endX) & ",Y:" & format(endY) & Chr(10) out.drawArc x, y, z, startX, startY, startZ, endX, endY, endZ, r, sense End If End Sub

Reply to
pele

ok maybe my question is not qute clear. so let me rephrase it:

how do you find out the direction of an arc? not where it's start and end points are (I guess "sense" tells me that) but if it's a clockwise or a counter-clockwise arc?

p.s. I'm talking about edges of a face that are arcs, not sketches of arcs.

Reply to
pele

Looking at Edge::GetCurveParams2 in the API Help, it states that it returns "curve direction (sense)". It looks like you have to find the underlying (sketch?) curve and compare the edge and curve...not very intuitive.

Looking at the available API Examples at

formatting link
I found "How to get the curve parameterization for the selected edge" example. Maybe it could shed some light?

Ken

Reply to
Tin Man

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.