.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Offset Line - Start & End Points

4 REPLIES 4
Reply
Message 1 of 5
doughtyk
758 Views, 4 Replies

Offset Line - Start & End Points

Hello:
I'm trying to obtain the start & end Points for an offset
line. I'm able to get the points for the original line by
using the StartPoint & EndPoint properties for the line
but due to having to declare the offset line as an object
instead of an array, the StartPoint & EndPoint properties
are not available for use. I'm using Visual Basic 2005 in
Visual Studio 2005. Any help would be appreciated.
4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: doughtyk

You have to cast the Object to a Line.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

wrote in message news:5090701@discussion.autodesk.com...
Hello:
I'm trying to obtain the start & end Points for an offset
line. I'm able to get the points for the original line by
using the StartPoint & EndPoint properties for the line
but due to having to declare the offset line as an object
instead of an array, the StartPoint & EndPoint properties
are not available for use. I'm using Visual Basic 2005 in
Visual Studio 2005. Any help would be appreciated.
Message 3 of 5
doughtyk
in reply to: doughtyk

Tony:
Thanks for your reply but I am still having trouble. I've
included the code that I am having trouble with below.
Any help will still be appreciated.

Dim objLine As Autodesk.AutoCAD.Interop.Common.AcadLine
Dim objOffsetAcadLine As Autodesk.AutoCAD.Interop.Common.AcadLine
Dim dblLineStartPt(0 To 2) As Double
Dim dblLineEndPt(0 To 2) As Double
Dim objOffsetLine As Object
Dim objOffsetDist As Double = 1.0
'
'Initialize Start and End Points
dblLineStartPt(0) = 0
dblLineStartPt(1) = 0
dblLineStartPt(2) = 0
dblLineEndPt(0) = 5
dblLineEndPt(1) = 5
dblLineEndPt(2) = 0
'
'Draw line in modelspace
objLine = acadApp.ActiveDocument.ModelSpace.AddLine(dblLineStartPt, dblLineEndPt)
'
'Offset line by 1.00"
objOffsetLine = (objLine.Offset(objOffsetDist))
'
'Convert Offset Line object to acad Line
objOffsetAcadLine = CType(objOffsetLine, Autodesk.AutoCAD.Interop.Common.AcadLine)

The above code draws the offset line but generates an
error in the last line - "Invalid Cast Exception Unhandled"

Ken
Message 4 of 5
jbooth
in reply to: doughtyk

The object returned by Line.Offset() could be a polyline, not a line. To be sure, run a test to find out the object's type:

System.Windows.Forms.MessageBox.Show(objOffsetLine.GetType().Name)

Once you know the type, you can then cast it correctly.
Message 5 of 5
doughtyk
in reply to: doughtyk

Gentlemen:
The solution to the aforementioned problem is as follows:

Dim objOffsetAcadLine As Autodesk.AutoCAD.Interop.Common.AcadLine

Dim objOffsetLine() As Object

objOffsetLine = (objLine.Offset(objOffsetDist))
'MsgBox(objOffsetLine.GetType.Name)
'
'Convert Offset Line object to acad Line
objOffsetAcadLine = CType(objOffsetLine(0), Autodesk.AutoCAD.Interop.Common.AcadLine)

Thanks to all who helped with the solution.
Ken

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost