Offset

#1
Hello.

When I use the Offset method with a LWPolyline object, I get an error. If I have used the paralell tool before, I don't get it, and I can use the method working properly with LWPolylines.

Thank you in advance.

#3
My code is:

Sub Offset(entity as Object)
Dim entity2 as Object
Set entity2 = entity.Offset(1)
End Sub

I have coded that when entering Intellicad, a paralell operation is executed, so I can run Offset without problems. Now, I have detected that when you use this method with polylines (I want to use it with closed polylines), it ignores the sign of the offset (- for decreasing, + for increasing). However, with circles it works properly. Why?

Thank you very much.

#4
Yolanda,

Sub myOffset()
Dim myEnt As LWPolyline
Dim Pnt As Point
ThisDocument.Utility.GetEntity myEnt, Pnt, "Select Entity"
myEnt.Highlight True
MsgBox "Got Me"
myEnt.Offset (-1)
myEnt.Offset (1)
myEnt.Highlight False
End Sub



------------------
Regards
John Finlay

#5
Hi.

I'm afraid it doesn't work. I have the same error for polylines. If I run once the parallel command, it works, but the offset with negative sign doesn't work. Always draws a positive offset (however, with circles and lines it works properly).

#6
Yolanda, John,

I could not get the offset to work on polylines either.

One time, using Yolanda's code with the getentity, it worked. I do not know why but it stopped working when I exited Intellicad and then restarted.

ssc

#7
Yolanda,

Try this it works for me:

Sub Offset()
Dim entity As Object
Dim entity2 As Object
Dim objLW As IntelliCAD.LWPolyline
Dim Pnt As Point
ThisDocument.Utility.GetEntity entity, Pnt, "Select Entity"
If entity.EntityType = vicLWPolyline Then
Set objLW = entity
Set entity2 = objLW.Offset(-1)
Set entity2 = objLW.Offset(1)
End If
End Sub

It appears that a polyline object needs to be set to the passed object and then offset it. This needs to be done when the object is a polyline.

ssc

#8
Hello.

I still get that Offset(-1) works exactly the same than Offset(1). They work increasing the size of the drawing, not decreasing it.

Thank you.

#9
Yolanda,

Offsetting polylines appears to have a problem. I tried my latest post on another machine and it wouldn't work until I manually offset the polyline then it would recognize the method in VBA. Even after that it would behave as you suggest and only do one of the offset directions, whichever comes first (+ or -).

John do you have any more thoughts?

ssc

#10
You should not be using:
Set entity = objLW.offset(-1)

Just use:
objLW.offset(-1#)

The documentation does not indicate that this method returns the object created, and it does not. Also, the offset is to be a double precision number not an integer.

Hope this works for you, it worked on my system.


------------------
Olde baldy

#11
Jack,

Thank you for the input. It appears that the double precision is the key. How come the offset works fine on other entities except lwpoly's without declaring double precision?

ssc


I tried this on a machine running Win2000, I still had the same problem of the poly line offset not working until I manually offset the polyline then vba would work. It worked fine in Win98se

[This message has been edited by ssc (edited 11-04-2002).]

#12
Jack, I can't make it work in my system (Windows 2000). It keeps drawing the new entity allways with an increase (only polylines).

What can I do to make it work?

Thank you very much to all of you.

#13
I tinkered around with this for quite a while. It seems, as ssc pointed out, it just will not work until you offset the object in ICAD. Then it works fine.

You can use F8 and single step thru the code and it works fine also.

Bottom line, I think there is a "bug" in the VBA code, but I did find a work around. The following code draws a line, offsets it, deletes both lines, and then does what your after. This has worked for me consistently.

Sub vbaOffset()
Dim entity As Object
Dim oLWPoly As IntelliCAD.LWPolyline
Dim Pnt As Point, dblOffset As Double
Dim myDoc As IntelliCAD.Document
Dim myLine1 As IntelliCAD.Line
Dim myLine2 As IntelliCAD.Line
Dim mySS As IntelliCAD.SelectionSet

'set the active document
Set myDoc = Application.ActiveDocument
'draw line 1
Set myLine1 = myDoc.ModelSpace.AddLine(Library.CreatePoint(0, 0), Library.CreatePoint(0, 5))
myLine1.Update
'offset the line 1
myLine1.Offset 1#
'delete the line 1
myLine1.Delete
'get line 2 created by the offset method
Set mySS = myDoc.SelectionSets.Add("mySS")
mySS.Select vicSelectionSetLast
Set myLine2 = mySS.Item(1)
'delete line 2
myLine2.Delete

'Ok, now do what were are really after
myDoc.Utility.GetEntity entity, Pnt, "Select Entity"
Set entity = HandleToObject(entity)
'get desired offset value
dblOffset = CDbl(InputBox("Enter desired offset:"))
If entity.EntityType = vicLWPolyline Then
Set oLWPoly = entity
oLWPoly.Offset dblOffset
End If
End Sub

Hope this works for you.

I am using ICAD 2001A PE running on Windows XP Home Edition. I do not think this problem is plantform dependent.

#14
Hi.

I can't make it work. I have tried offsetting the line with -1, but I get the same result, and polylines always offset with a positive value. The only thing I can do to solve this problem is to use the _PARALLEL command from VBA.

Any other suggestions?

Thank you very much.

#15
Yolanda,

I'm lost. The offset method produces some really strange results with complex entities, (polylines). Positive and negative numbers work ok for me but, sometimes, if I offset a line 1 unit and a polyline 1 unit, they are not offset the same amount.

I've tweaked a routine that works about as good as I can get it. It will offset lines, arcs, circles, and polylines??. It includes error trapping. If you would like a copy, I could post it or email it.

Sorry, but there just does not seem to be a fix.