AutoCAD offset bug?

AutoCAD offset bug?

capuano3d
Enthusiast Enthusiast
1,276 Views
8 Replies
Message 1 of 9

AutoCAD offset bug?

capuano3d
Enthusiast
Enthusiast

Hello

 

In trying to offset the polyline in the image, instead of as expected getting a full polyline, the outcome is actually several 'partitioned' polylines. In the image the red was offset from the green 0.35 units upwards.

 

capuano3d_0-1698847738709.png

 

I'd say it's an AutoCAD bug - here for someone maybe to confirm or for the record.

 

Dwg attached.

 

Thanks

 

Alan

 

0 Likes
Accepted solutions (2)
1,277 Views
8 Replies
Replies (8)
Message 2 of 9

ВeekeeCZ
Consultant
Consultant

Well, now and then this happens. Coords are high, lengthy polyline... the process ran out of valid digits of precision.

 

Move it towards 0,0, do the offset, then move it back.

0 Likes
Message 3 of 9

capuano3d
Enthusiast
Enthusiast

Hi there, it turns up that this problem is happening quite frequently in our project, with many different polylines, which is very worrying as they are long polylines that will be used for quantification purposes.

 

Does anyone know by any chance of some lisp/vba/.net routine or other method that would work more reliably, as unfortunately it ends up that we can't trust AutoCAD offset.

 

Thanks

0 Likes
Message 4 of 9

leeminardi
Mentor
Mentor

AutoCAD stores coordinates to about 15 significant digits.  By positioning the polyline as you have a million units frm the origin you have consumed 7 of them for positioning which still leaves about 8 decimal places to work with.  I am not sure why offset fails to create an offset at the positions noted below on your orginal drawing.  It could have to do with difficulty in calculating the center of curvature and bulge for an object far away from 0,0,0.

leeminardi_0-1699717038544.png

Offset worked fine when the polyline was moved so that one end was at 0,0,0.

 

Is there a strong reason for positioning the lines a million units from World origin?

 

lee.minardi
0 Likes
Message 5 of 9

capuano3d
Enthusiast
Enthusiast
Thanks for your insights. Even with your explanation I struggle a bit to
understand the malfunctioning - sounds like we have just to accept and live
along it.

And yes there's a reason - it's a georeferenced asset, which interacts with
other systems.


0 Likes
Message 6 of 9

ВeekeeCZ
Consultant
Consultant
Accepted solution

@leeminardi wrote:

AutoCAD stores coordinates to about 15 significant digits.  ...

 


 

Ok, we both know this... but how would you explain that when I open it in Br1cs, it makes an offset without blinking?

There are obviously some methods to avoid this issue... 

 

@capuano3d 

does moving it toward 0,0 always solve the issue? If so, that could be automated by lisp routine.

0 Likes
Message 7 of 9

Anton_Huizinga
Advocate
Advocate

Maybe that software uses other calculation methods. The core is more modern and younger than the AutoCAD core. Maybe it internally calculates with a local coordinate system or uses a different mathematical approach. 

 

In Dynamo, for example, large coordinates are also a problem, but at least you are able to script the movement towards 0.0 and back yourself.

Message 8 of 9

leeminardi
Mentor
Mentor

@ВeekeeCZ wrote:

@leeminardi wrote:

AutoCAD stores coordinates to about 15 significant digits.  ...

 


 

Ok, we both know this... but how would you explain that when I open it in Br1cs, it makes an offset without blinking?

There are obviously some methods to avoid this issue... 

 



@ВeekeeCZ I don't know why but studying when and where offset fails for the polyline far from 0,0 I'll take a wild guess!  Some of the arc segments are only slightly tangent with adjacent straight or arc segements.  The green lines in the image below are radial lines for arc segments.  For tangent arc segement they should share a radial line (some don't). The offset failed at #1 but not at #2!   In creating the offset geometry the calcuation of the intersection point of the offset arc with an offset line (or another arc) is first alculated. If this is done numerically the computation may stop if a desired precision is not reached within the maximum iterations allowed.  That threshold may be reached sooner if with the reduced precision of geometry far from the world origin.

There may also be a sensitivity to whether the offset arc needs to be extended or trimmed beyond the angle of the orginal arc.  This can be seen by the fact that where offset fails is different for one side than the other.  

leeminardi_0-1699741229071.png

 

Offset is probably one of the first commands implemented in AutoCAD. I remember coming from another CAD system in the early 80's and trying out AutoCAD for the first time.  I struggled  looking for the "parallel" command and couldn't find it and then wondering who the hell named it "offset"!😄

 

lee.minardi
0 Likes
Message 9 of 9

ВeekeeCZ
Consultant
Consultant
Accepted solution

I see... thx

 

Offset: we have it localized as Ekvid... which is an artificial shortcut for Ekvidistanta (or Equidistant in eng)... none of it is really a local word, but I guess it is more understandable than offset. But still, I would like to hear some explanation why it's not "parallel".

 

@capuano3d 

 

If you need a lisp to automate the process, here you go. Not sure whether Dynamo is an option for you.

 

(vl-load-com)

(defun c:OffsetAtOrigin ( / *error* osm sel psel pside psideon ang oside cop off)
  
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end"))
      (princ (strcat "\nError: " errmsg)))
    (if osm (setvar 'osmode osm))
    (princ))
  
  (or *off0-dst* (setq *off0-dst* (abs (getvar 'offsetdist))))
  (setq *off0-dst* (cond ((getdist (strcat "\nSpecify offset distance <" (rtos *off0-dst*) ">: "))) (*off0-dst*)))
  (setq osm (getvar 'osmode))
  
  (while (and (setq sel (entsel "\nSelect object to offset: "))
	      (or (= "LWPOLYLINE" (cdr (assoc 0 (entget (car sel)))))
		  (prompt "\nError: Selected object is not polyline."))
	      (setq org (vlax-ename->vla-object (car sel)))
	      (setq psel (trans (cadr sel) 1 0))
	      (setvar 'osmode 0)
	      (setq pside (getpoint "\nSpecify point on side to offset: "))
	      (setq pside (trans pside 1 0))
	      )
    
    (setq psideon (vlax-curve-getclosestpointto org pside))
    (setq ang (- (angle (vlax-curve-getfirstderiv org (vlax-curve-getParamAtPoint org psideon)) '(0 0 0))
		 (angle psideon pside)))
    (setq oside (if (or (equal ang (* pi 0.5) 1e-6)
			(equal ang (* pi -1.5) 1e-6)
			)
		  -1
		  +1))
    (setq cop (vla-copy org))
    (vla-move cop (vlax-3d-point psel) (vlax-3d-point '(0 0 0)))
    (setq off (vlax-invoke cop 'Offset (* *off0-dst* oside)))
    (foreach obj off
      (vla-move obj (vlax-3d-point '(0 0 0)) (vlax-3d-point psel)))
    (vla-erase cop)
    )
  (*error* "end")
  )

 

0 Likes