Arc direction defining problem

Arc direction defining problem

danijel.radenkovic
Collaborator Collaborator
4,497 Views
25 Replies
Message 1 of 26

Arc direction defining problem

danijel.radenkovic
Collaborator
Collaborator

Hello to all,

The short description of what I am trying to do is recreating AutoCAD geometry using Inventor. The geometry that I am talking consists of arcs and lines. Hopefully, @ВeekeeCZ and @CADaSchtroumpf helped me to export geometry coordinates from AutoCAD to excel. Thank you very much for that cause it was not possible without your help and I am not pretty familiar with lisp.

 

If you take a look to this video you will see how it works:

https://www.youtube.com/watch?v=3LOA48OI3X8&feature=youtu.be

 

There is something that I missed to think about. It is arc direction.

img.png

By setting "True" or "False" at the end of the code line, you decide about arc direction.

 

I am looking for the any new parameter which will be exported from AutoCAD, which will help me in defining the right arc direction.

Otherwise, there is a problem as it is showed on this video:

https://www.youtube.com/watch?v=JHqIfVHad4E&feature=youtu.be

Any help is very appreciated.

Danijel


 

Inventor 2018/Windows 10 x64
If this information was helpful, please consider marking it as an Accepted Solution by using the Accept as Solution. Kudos are also gladly accepted.
0 Likes
4,498 Views
25 Replies
Replies (25)
Message 2 of 26

_gile
Consultant
Consultant

Hi,

 

In AutoCAD, ARC entites are always conter-clockwise.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 3 of 26

danijel.radenkovic
Collaborator
Collaborator

@_gile wrote:

Hi,

 

In AutoCAD, ARC entites are always conter-clockwise.


Yes, I know that. But imagine that I have exported just a coordinates of arcs (StartPoint, MidPoint & EndPoint) and when I look at the excel worksheet, I don't see anything but the numbers which can help me to re-create all arcs again, but in Inventor. What would be the key parameter which will help me to re-create arc. Maybe coordinates of midpoint?

For example, these two arcs (red & magenta) have the same start,end and center point but not the same midpoint. Maybe by arc's midpoint I can be sure that right arc is re-created. Any other opinion?

Capture.PNG

 

 

Inventor 2018/Windows 10 x64
If this information was helpful, please consider marking it as an Accepted Solution by using the Accept as Solution. Kudos are also gladly accepted.
0 Likes
Message 4 of 26

_gile
Consultant
Consultant

Assuming arcs are always conter clockwise, with Center Point, StartPoint and EndPoint as in the picture, you'll get the magenta arc.

To get the red arc, you have to swap StartPoint and End Point.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 5 of 26

danijel.radenkovic
Collaborator
Collaborator

Hello sir,

I will try to explain it better. Let's imagine that you have created 3 connected arcs and you gave me just coordinates of it.

Now I have to re-create them but in Inventor. I don't know how they look in you sketch. There are many possible sketches where all of three arcs will have the same coordinates (startpoint,endpoint,centerpoint).

Capture1.PNG

 

What will be the key parameter (exported from AutoCAD) to ensure that your sketch and my sketch will be the same?

 

To confirm that all of the possible sketches have the same start,end and center, I have overlapped the sketches:

https://www.youtube.com/watch?v=okCfWum-91A&feature=youtu.be

Inventor 2018/Windows 10 x64
If this information was helpful, please consider marking it as an Accepted Solution by using the Accept as Solution. Kudos are also gladly accepted.
0 Likes
Message 6 of 26

_gile
Consultant
Consultant

Please, explain how you get the arcs data in AutoCAD and which data are exported to Excel, in all your examples, you need more than 2 points to define the arcs, at least a radius and probably the arc center.

 

With AutoCAD, an arc is typically defined by a center point, a radius, a start angle and an end angle (and possibly a normal -or extrusion direction- if it does not lies on the XY plane).

These data are necessary and suffisant to define the arc.

They can be computed from 3 points:

  • a point at one end, a point at the other end and a point somewhere else on the arc in this case the topography will determin which point is the start one and which is the end one so that the arc is conter clockwise.
  • a point at center of the arc, a start point and a end point, in this case, the arc will start at start point and go conter clockwise to end point.


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 7 of 26

ВeekeeCZ
Consultant
Consultant

Try THIS routine if returns the appropriate value to you. I think it could.

0 Likes
Message 8 of 26

_gile
Consultant
Consultant

Assuming you're using such a method in Inventor:

AddByCenterStartendPoint(CenterPoint, StartPoint, EndPoint, [CounterClockwise = True])

You just need to pass this method the data in the right order, that's to say the arc start point is the point at arc start angle and the arc end point is the point on the arc end angle with angles going counter clockwise.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 9 of 26

ВeekeeCZ
Consultant
Consultant

Just posting the LINK to the code which danijel refers to at the first post.

0 Likes
Message 10 of 26

hencoop
Advisor
Advisor

One additional bit of information is that Start Angle may be larger than End Angle if the ARC crosses the 0° vector.  E.g., Start Angle is 5.5 (1.75 PI) and the End Angle is 0.75 (0.2387 PI).

 

If your data does not account for determining the order of the angles in AutoCAD you will not be able to faithfully recreate them. 

AutoCAD User since 1989. Civil Engineering Professional since 1983
Product Version: 13.6.1963.0 Civil 3D 2024.4.1 Update Built on: U.202.0.0 AutoCAD 2024.1.6
                        27.0.37.14 Autodesk AutoCAD Map 3D 2024.0.1
                        8.6.52.0 AutoCAD Architecture 2024
0 Likes
Message 11 of 26

hencoop
Advisor
Advisor

The Forum kept generating an error posting as I tried several times.  This edit is to remove the duplicate.

AutoCAD User since 1989. Civil Engineering Professional since 1983
Product Version: 13.6.1963.0 Civil 3D 2024.4.1 Update Built on: U.202.0.0 AutoCAD 2024.1.6
                        27.0.37.14 Autodesk AutoCAD Map 3D 2024.0.1
                        8.6.52.0 AutoCAD Architecture 2024
0 Likes
Message 12 of 26

Kent1Cooper
Consultant
Consultant

@_gile wrote:

Please, explain how you get the arcs data in AutoCAD and which data are exported to Excel....

 

With AutoCAD, an arc is typically defined by a center point, a radius, a start angle and an end angle....


I agree.  What are you sending to Excel?  All the discussion including supplying the start point and end point would require extracting something from AutoCAD by calculation, and not directly from an Arc's entity data, or VLA properties, or whatever you're using.  AutoCAD doesn't store the endpoints, only the center and radius and the angles from the center to the start and end points.  Given those, and that the direction an Arc "proceeds" between them is always counter-clockwise, there is no ambiguity for AutoCAD about the direction, but I'm not familiar with the kinds of inputs needed in Inventor, or whether there are optional ways of defining an Arc there, as there are in AutoCAD [which has something like eight ways to draw one, but once drawn, only one way to store the information defining it].

Kent Cooper, AIA
0 Likes
Message 13 of 26

ActivistInvestor
Mentor
Mentor
Given the vector from the start point to the end point, calculate on which side of that vector the midpoint lies. Use that as your "if" condition.
0 Likes
Message 14 of 26

danijel.radenkovic
Collaborator
Collaborator

Where is missed my last post?

 

Inventor 2018/Windows 10 x64
If this information was helpful, please consider marking it as an Accepted Solution by using the Accept as Solution. Kudos are also gladly accepted.
0 Likes
Message 15 of 26

danijel.radenkovic
Collaborator
Collaborator

@Kent1Cooper wrote:

@_gile wrote:

Please, explain how you get the arcs data in AutoCAD and which data are exported to Excel....

 

With AutoCAD, an arc is typically defined by a center point, a radius, a start angle and an end angle....


I agree.  What are you sending to Excel?  All the discussion including supplying the start point and end point would require extracting something from AutoCAD by calculation, and not directly from an Arc's entity data, or VLA properties, or whatever you're using.  AutoCAD doesn't store the endpoints, only the center and radius and the angles from the center to the start and end points.  Given those, and that the direction an Arc "proceeds" between them is always counter-clockwise, there is no ambiguity for AutoCAD about the direction, but I'm not familiar with the kinds of inputs needed in Inventor, or whether there are optional ways of defining an Arc there, as there are in AutoCAD [which has something like eight ways to draw one, but once drawn, only one way to store the information defining it].


I have replied but my post is missed. I will try to re-write it again by remembering. Admin has to pay attention cause posts are missing after few minutes!

 

Hello to all,

Thank you very much for the many replies. Let's start with the answering.

 

1. What are you sending to Excel?

Some people on this community helped me with the .lisp script. Whole discussion is available on the LINK

How script works? VIDEO

Script sends coordinates (x,y) of points for sketch entities (arcs and lines). For the arcs, script sends StartPoint, EndPoint and CenterPoint coordinates to excel worksheet. So, in the excel worksheet, one row represents one geometric entity. BUT, rows (entities) are not sorted, so I am using an macro to sort them by clicking on the button "Run CST". Now, entities are sorted (entity below entity) as they are connected in AutoCAD.

This is very important cause my Inventor code works by method "WHERE PREVIOUS ENTITY ENDS, NEXT ENTITY BEGIN".

Where is a problem?

Inventor code to create arc looks like on the image below, where "True" means CCW direction of the arc.

img.png

The problem happens when the new arc has different direction than previous. For me, it is not a problem to create few more "IF Statements" but what to put into it? How to catch change of direction? I need some "mathematical" or "geometrical position" conditions to easily recognize change of direction in AutoCAD.

 

2. whether there are optional ways of defining an Arc there, as there are in AutoCAD

Inventor has two (few) possible ways of creating a arc programmatically. First one is "Three Point Arc", second one is "Center Point Arc". Unfortunately, "Three Point Arc" method has the software (Inventor) issue to create arc, in some special cases.

 

Inventor 2018/Windows 10 x64
If this information was helpful, please consider marking it as an Accepted Solution by using the Accept as Solution. Kudos are also gladly accepted.
0 Likes
Message 16 of 26

_gile
Consultant
Consultant

The data you got from AutoCAD for arcs with start point, end point and center always describe CCW arcs (AddByCenterStartEndPoint counterClockWise arg = true).

When sorting the entities to connect them, if you reverse the start point / end point order of an arc that means the arc should now be CW (AddByCenterStartEndPoint counterClockWise arg = False).

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 17 of 26

danijel.radenkovic
Collaborator
Collaborator

@_gile wrote:

The data you got from AutoCAD for arcs with start point, end point and center always describe CCW arcs (AddByCenterStartEndPoint counterClockWise arg = true).

When sorting the entities to connect them, if you reverse the start point / end point order of an arc that means the arc should now be CW (AddByCenterStartEndPoint counterClockWise arg = False).

 


That's true. But what could tell me when to swap start/end point of arc? Me? By looking at the AutoCAD dwg and decide that some fifth arc has to swap start with end point? No, that is not what I want to do.

I have done it manually but I am not satisfied with solution. Firstly, I have added a new column "Inverse Direction" in Excel worksheet which allows me to chose NO if I want to keep CCW direction and Inventor will get "True" as input for arc direction, or to chose YES and Inventor will know when to change direction and use False for the arc direction.

IMG11.PNG

 

This is not good solution but I still don't have better idea.

Inventor 2018/Windows 10 x64
If this information was helpful, please consider marking it as an Accepted Solution by using the Accept as Solution. Kudos are also gladly accepted.
0 Likes
Message 18 of 26

_gile
Consultant
Consultant

Appologies for my poor English, but I thaught I was clear since the begining of this thread

 

From the doc help of the Arc ActiveX object:

 

Arc.png

So the data you get from AutoCAD (StartPoint and EndPoint) will always draws the arc CCW.

 

 

Assuming in AutoCAD you have a line with start point = (0, 0) and end point = (10, 0) you want to connect to a arc which start point = (10, -6), end point = (10, 0) and center point = (10, -3):

 

Arc_2.png

 

If Inventor automation requires to swap the arc start point and end point so that the line end point equals the new arc start point, you need to set the CounterclockWise argument to False.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 19 of 26

danijel.radenkovic
Collaborator
Collaborator

@_gile wrote:

Appologies for my poor English, but I thaught I was clear since the begining of this thread

 

From the doc help of the Arc ActiveX object:

 

Arc.png

So the data you get from AutoCAD (StartPoint and EndPoint) will always draws the arc CCW.

 

 

Assuming in AutoCAD you have a line with start point = (0, 0) and end point = (10, 0) you want to connect to a arc which start point = (10, -6), end point = (10, 0) and center point = (10, -3):

 

Arc_2.png

 

If Inventor automation requires to swap the arc start point and end point so that the line end point equals the new arc start point, you need to set the CounterclockWise argument to False.


Hello sir,

I absolutely understand what you are saying but there are some differences between AutoCAD's and Inventor's method to create a arc.

AutoCAD always creates arcs in CCW direction while Inventor can do it in both of directions without swapping a start/end points.

 

The reason why I have started this topic was a problem to get the information which arc in the AutoCAD sketch has switched points.

 

After exporting a points to Excel, points are not sorted by the equation: EndPointXOfPreviousEntity=StartPointXOfNextEntity so I have used Excel macro to sort them.

image112.PNG

While CCW arcs are exported fine, CW arcs are exported from AutoCAD with swapped points. So, the other problem was to swap points of CW arcs again but this time in Excel. Excel macro also recorded when cells are swapped values and it is recorded in the column "G".

That is the key parameter  that I have used in Inventor to create CW arcs. If the "G" cell value is "Yes" then create CW arc, else create CCW arc.

Here is a video how it works. Project is still not finished, but I will upload whole project at the end.

https://www.youtube.com/watch?v=lV3h36AVZMw&feature=youtu.be

 

Inventor 2018/Windows 10 x64
If this information was helpful, please consider marking it as an Accepted Solution by using the Accept as Solution. Kudos are also gladly accepted.
0 Likes
Message 20 of 26

john.uhden
Mentor
Mentor

Oops.  I guess an errant finger of mine hit some incorrect key and either I lost my draft or it went through unfinished.

 

Just a thought.  Instead of dealing with separate arcs and sorting them, how about using a polyline consisting of arced segments.  Each segment has a "bulge" factor which controls both the size of the radius and the direction of curvature.  A positive bulge means CCW and a negative bulge means CW.  We can provide you the math in AutoLisp to compute the centerpoint and radius. Also, the straight line segments can be handled the same way and even be comingled with bulged segments (when such conditions are present).

John F. Uhden

0 Likes