Author Topic: Offset issue (Arcs and lines offset different directions)  (Read 2740 times)

0 Members and 1 Guest are viewing this topic.

jlatimer11

  • Mosquito
  • Posts: 13
Offset issue (Arcs and lines offset different directions)
« on: December 11, 2012, 03:28:09 PM »
Code - vb.net: [Select]
  1.         Dim myDB As DatabaseServices.Database
  2.         Dim myDWG As ApplicationServices.Document
  3.         Dim myEd As EditorInput.Editor
  4.         Dim myTransMan As DatabaseServices.TransactionManager
  5.         Dim myTrans As DatabaseServices.Transaction
  6.  
  7.         myDWG = ApplicationServices.Application.DocumentManager.MdiActiveDocument
  8.         myDB = myDWG.Database
  9.         myEd = myDWG.Editor
  10.         myTransMan = myDB.TransactionManager
  11.         myTrans = myTransMan.StartTransaction
  12.  
  13.         Using acLckDoc As DocumentLock = myDWG.LockDocument()
  14.  
  15.             Dim myItems As ArrayList = selItemsByLayer(myDWG, myDB, myDWG.Editor, layername)
  16.  
  17.             For Each ent As Entity In myItems
  18.  
  19.                 Dim newent As ObjectIdCollection = Tools.Offset(ent.ObjectId, 0.03)
  20.  
  21.                 Dim myNewEnt As Entity = newent(0).GetObject(OpenMode.ForRead, False, False)
  22.  
  23.                 myNewEnt.Color = Colors.Color.FromColorIndex(Colors.ColorMethod.ByColor, 1)
  24.  
  25.             Next
  26.  
  27.         End Using
  28.  
  29.         myTrans.Commit()
  30.         myTrans.Dispose()



So here's my dilemma:

As you can see in the picture, I am offsetting the white line .030". Whether I use DotNetArx or write the code myself, I'm getting the above issue where the arcs and lines are offset to different sides. I don't care if they are offset one way or the other, but I want them to be on the same side (inside or outside).

My real question is: What governs which side the lines and/or arcs are offset on? I was under the assumption that it depended on whether or not the offset distance was positive or negative, but that only seems to be true on polylines.

I COULD make everything a polyline and offset it as I've done in the past, but I'd rather be able to offset each item individually because what I'm attempting to do would work better offsetting individual lines.

Any thoughts? Ideas?

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: Offset issue (Arcs and lines offset different directions)
« Reply #1 on: December 11, 2012, 03:50:41 PM »
Hi,

From ObjectARX docs (arxmgd.chm) in OffestCurve2d class:
Quote
The base curve may be offset in either of two directions by specifying a positive or negative offset value.
The direction depends on start and end points.
As you probably know, Arc entities are always counter-clockwise, if you look at the arcs in your drawing, you'll see that, looking them from start point to end point they're all offseted to the right (when specifying a positive offset value as you did).
Speaking English as a French Frog

Jeff H

  • Needs a day job
  • Posts: 6144
Re: Offset issue (Arcs and lines offset different directions)
« Reply #2 on: December 11, 2012, 04:14:10 PM »
Is it one polyline?
 
What happens if you use JOIN command then try?

Jeff H

  • Needs a day job
  • Posts: 6144
Re: Offset issue (Arcs and lines offset different directions)
« Reply #3 on: December 11, 2012, 04:57:27 PM »
You using GetOffsetCurves?
 
Quote

 
If the offsetDist value is negative, it is usually interpreted as being an offset to make a smaller curve (that is, for an arc it would offset to a radius that is offsetDist less than the starting curve's radius). If the negative value has no meaning in terms of making the curve smaller, a negative offsetDist may be interpreted as an offset in the direction of smaller X,Y,Z WCS coordinates. This is not enforced, so custom entities can interpret the sign of the offsetDist value however they want.
The entities returned in the offsetCurves array are dynamically allocated, but have not been added to an AcDbDatabase yet. So, the application that calls this function is responsible for their memory. If they are subsequently appended to a database, then the database takes over responsibility for their memory. Otherwise, the application is responsible for deleting them when they are no longer needed.

jlatimer11

  • Mosquito
  • Posts: 13
Re: Offset issue (Arcs and lines offset different directions)
« Reply #4 on: December 11, 2012, 05:43:43 PM »
You using GetOffsetCurves?
 
Quote

 
If the offsetDist value is negative, it is usually interpreted as being an offset to make a smaller curve (that is, for an arc it would offset to a radius that is offsetDist less than the starting curve's radius). If the negative value has no meaning in terms of making the curve smaller, a negative offsetDist may be interpreted as an offset in the direction of smaller X,Y,Z WCS coordinates. This is not enforced, so custom entities can interpret the sign of the offsetDist value however they want.
The entities returned in the offsetCurves array are dynamically allocated, but have not been added to an AcDbDatabase yet. So, the application that calls this function is responsible for their memory. If they are subsequently appended to a database, then the database takes over responsibility for their memory. Otherwise, the application is responsible for deleting them when they are no longer needed.

Yeah, but I'm at a loss as to how I can determine whether or not to use a negative or positive value. It still doesn't explain why some lines are being offset to the other side.

Jeff H

  • Needs a day job
  • Posts: 6144
Re: Offset issue (Arcs and lines offset different directions)
« Reply #5 on: December 11, 2012, 06:05:08 PM »
Taking what was quoted from the docs and looking at the picture it seems to make sense me as a positive value offsets the arcs are on the "outside" or the side which the radius is larger.
 
Now figuring out which side would make it larger is for those smart guys like gile who have a good understanding of all that smart people stuff.
 
 
 

TheMaster

  • Guest
Re: Offset issue (Arcs and lines offset different directions)
« Reply #6 on: December 12, 2012, 09:15:10 PM »
You using GetOffsetCurves?
 
Quote

 
If the offsetDist value is negative, it is usually interpreted as being an offset to make a smaller curve (that is, for an arc it would offset to a radius that is offsetDist less than the starting curve's radius). If the negative value has no meaning in terms of making the curve smaller, a negative offsetDist may be interpreted as an offset in the direction of smaller X,Y,Z WCS coordinates. This is not enforced, so custom entities can interpret the sign of the offsetDist value however they want.
The entities returned in the offsetCurves array are dynamically allocated, but have not been added to an AcDbDatabase yet. So, the application that calls this function is responsible for their memory. If they are subsequently appended to a database, then the database takes over responsibility for their memory. Otherwise, the application is responsible for deleting them when they are no longer needed.

Yeah, but I'm at a loss as to how I can determine whether or not to use a negative or positive value. It still doesn't explain why some lines are being offset to the other side.

The extrusion vector most likely has something to do with that.

TheMaster

  • Guest
Re: Offset issue (Arcs and lines offset different directions)
« Reply #7 on: December 12, 2012, 09:19:52 PM »
Quote from: jlatimer11 link=topic=43374.msg486000#msg486000
I COULD make everything a polyline and offset it as I've done in the past, but I'd rather be able to offset each item individually because what I'm attempting to do would work better offsetting individual lines.

Any thoughts? Ideas?

That's certainly is the easier approach, and has a different result, because offsetting individual line and arc entities will produce offset entities whose endpoints are not coincident. What is it that you're doing that is made easier by offsetting individual entities?