select last object created such as polyline

select last object created such as polyline

jalal.mousa
Advocate Advocate
660 Views
3 Replies
Message 1 of 4

select last object created such as polyline

jalal.mousa
Advocate
Advocate

i am trying to find a way to select last polyline created using vba command

i am sending a below command to Autocad from excel to draw polyline

MyDWG.SendCommand "Pline" & vbCr

is there a way to select the object i created and return its properties such as area

0 Likes
Accepted solutions (1)
661 Views
3 Replies
Replies (3)
Message 2 of 4

Ed__Jobe
Mentor
Mentor
Accepted solution

The best way is to use the api to create a LWPolyline. The example in Help for the AddLWPolyline method shows you how. The method returns a LWPolyline object of the entity just created. Then you can modify it's properties.

 

If you insist on using the command line, note that the SendCommand method is asyncronous. That is, it will run after the vba method that calls it is finished. Your only option would be to continue issuing commands, lile "Select L".

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

Message 3 of 4

jalal.mousa
Advocate
Advocate

Hi Ed

Thanks for solution

I agree with you that  AddLWPolyline will be better solution and i used this until now (adding points to create polyline)

(i am fairly new to coding sorry if i can't explain my self )but had an issue creating polyline with Arc(see attached image  as an example) 

so i thought sending commands below allow me to draw actual polyline instead of points

 

MyDWG.SendCommand "pline" & vbCr
MyDWG.SendCommand "select" & vbCr & "L" & vbCr & vbCr

 

selection of last item works fine but my issue now how i can get area of this selected item and hatch in red for example

 

0 Likes
Message 4 of 4

Ed__Jobe
Mentor
Mentor

Since you are using regular commands, just do it at the command line without using a mouse and note the keys that you used. They’re save in the command history (F2). Use versions of commands that only accept input at the command line. They start with a dash, like -HATCH instead of HATCH. Then you don’t have to worry about dialogues interrupting you. 

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes