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

VB.NET, AutoCAD 2010 and ObjectID/BlockTableRecords

1 REPLY 1
Reply
Message 1 of 2
Anonymous
1348 Views, 1 Reply

VB.NET, AutoCAD 2010 and ObjectID/BlockTableRecords

Hello,

Posted recently with a need for some direction. I am somewhat of a beginner at VB.NET but have good experience with AutoCAD. I have read up on the AutoDesk Reference Material on the API.

My task is to GetObject (a line previously residing on the documet) and get it's StartPoint and EndPoint. Then select points on that line and BREAK it (simulate the Break Command) and create two (2) new lines with AppendEntity. The two (2) new lines will have one (1) with a StartPoint of the original line and a new EndPoint (selected with GetPoints) and the other with a new StartPoint (selected with GetPoints) and the original EndPoint. If you can follow this you see that it simulates the Break Command (or Trim Command between two (2) points).

Someone responded with this sample code which seems straight forward and simple, but I get an error when running it, "Error binding to target method". The problem lies within the Sub statement.

_
Sub ModifyLine(ByRef tr As Transaction, ByVal objID As ObjectId)
Dim e As Entity = tr.GetObject(objID, OpenMode.ForRead)
If TypeOf e Is Line Then
Dim l As Line = tr.GetObject(objID, OpenMode.ForWrite)
Dim sPt As New Point3d(0, 0, 0)
Dim ePt As New Point3d(1, 1, 0)
l.StartPoint = sPt
l.EndPoint = ePt
End If
End Sub

I would have been able to work with this code segment to achieve what I wanted to accomplish but seems this is too simple and the method of doing this is much more involved. And it kicks back an error.

Without sitting down and writing a sample code segment for me (please I am not asking someone to do it for me) can you analyze what I am trying to do and give me the direction of how to go about it. Please just point me in the right direction and I will do the rest.

THX,
Dan
1 REPLY 1
Message 2 of 2
Anonymous
in reply to: Anonymous

The Sub routine you listed cannot be attributed as "CommandMethod": no
argument is allowed in that sub.

To use that Sub, you need to start a Transaction, obtain an Entity's
ObjectId, obviously.


"dan.mcrae" wrote in message news:6283270@discussion.autodesk.com...
Hello,

Posted recently with a need for some direction. I am somewhat of a beginner
at VB.NET but have good experience with AutoCAD. I have read up on the
AutoDesk Reference Material on the API.

My task is to GetObject (a line previously residing on the documet) and get
it's StartPoint and EndPoint. Then select points on that line and BREAK it
(simulate the Break Command) and create two (2) new lines with AppendEntity.
The two (2) new lines will have one (1) with a StartPoint of the original
line and a new EndPoint (selected with GetPoints) and the other with a new
StartPoint (selected with GetPoints) and the original EndPoint. If you can
follow this you see that it simulates the Break Command (or Trim Command
between two (2) points).

Someone responded with this sample code which seems straight forward and
simple, but I get an error when running it, "Error binding to target
method". The problem lies within the Sub statement.

_
Sub ModifyLine(ByRef tr As Transaction, ByVal objID As ObjectId)
Dim e As Entity = tr.GetObject(objID, OpenMode.ForRead)
If TypeOf e Is Line Then
Dim l As Line = tr.GetObject(objID, OpenMode.ForWrite)
Dim sPt As New Point3d(0, 0, 0)
Dim ePt As New Point3d(1, 1, 0)
l.StartPoint = sPt
l.EndPoint = ePt
End If
End Sub

I would have been able to work with this code segment to achieve what I
wanted to accomplish but seems this is too simple and the method of doing
this is much more involved. And it kicks back an error.

Without sitting down and writing a sample code segment for me (please I am
not asking someone to do it for me) can you analyze what I am trying to do
and give me the direction of how to go about it. Please just point me in the
right direction and I will do the rest.

THX,
Dan

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