Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


ACAD command line: Draw line and then select line by id/name or db-nr

Posted on 2010-08-26
Medium Priority
Last Modified: 2013-12-04

In Autocad i want to select individual lines preferably with Lisp.
I'll generate lines with lisp and then later on want to delete/manipulate
these lines one by one.

What is the best way to achieve this? My guess is that i have to give the
lines/objects unique identifiers somehow, so they are adressable for
selection later on?
Question by:kiggsondrome
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
  • +1
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 33539235
You can use the entity handle for this purpose. You can record the handles as and when the entity is created and later use this handle to delete them.

The function to do this is the "handent"


Author Comment

ID: 33539628

Handent works great, where i still see a problem is that
the records for the handles would have to be written
to an excel sheet because i'm using excel to generate
the lisp that does the drawing and then with a new lisp
later on the modifications.

This could work through vba, i'm just not sure if it will be
reasonably fast for thousands of lines.

If i could define or change the handle id it would be faster
i think. Or is there a better way adressing the lines/objects
with xdata?
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 33539650
Can you write the generated handles to a text file and, once completed, import the text file to excel?
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.


Author Comment

ID: 33539736

That could be fast enough i think. The problem here is that i use one row
per acad line in excel, so the handles would have to get placed on the
row that created it in the first place. Unfortunately i don't see a reliable
way to get that right without complications.

LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 33539792
If that can be fast enough then you can considering writing your preferred key together with the generated handle and then import the two columns into excel. Thereafter you can use vlookup to correlate the two.

Xdata is also a good option. I have tried it at some point in time but had been facing problems and then abandoned the idea. You might like to give it a go. Do you need help with it or can you handle it on your own?

Author Comment

ID: 33539955

If you remember how to attach a key or xdata to an acad
line it would help me a lot. It seems i can't find that info right now.

I'll give the vlookup in excel a try as soon as i really need it.  
LVL 43

Accepted Solution

Saqib Husain, Syed earned 2000 total points
ID: 33539982
LVL 10

Expert Comment

ID: 33565964
Would storing them as a GROUP in AutoCAD work for you? Group info is stored in AutoCAD and then it can be accessed later.
LVL 11

Expert Comment

ID: 33573705
What do you mean by later access them and delete/manipulate them?

Are you going to delete/manipulate them during the same program execution? Or will this be done later during another program execution, perhaps even another day in another autocad session?

There's several ways to do any of this. Storing the handles is one way if you need access later. If the same program that creates them will later delete/manipulate them, you could just keep adding them to a selection set as they are created for later deletion/manipulation.

You could put them on seperate layers, you could attached Xdata to them to give them unique identifiers and/or other data that lets your program later know what they are and their purpose.

What determines what/when they get deleted/manipulated? Perhaps you just erase them all and redraw in their manipulated state (could be slow if there's thousands of lines) but could also be insignificant...especially if you are using something like Entmake as opposed to calling the line command.

You could also not draw lines but instead make them as blocks...but as Borgunit said, Groups mighht work better as you can easily select by group and manipulating the lines within the group is a lot easer than from within a block definition.

What version of AutoCAD? Newer versions have paremetric and geometric constraints that might allow you to manipulate them by manipulating the constraints as opposed to the lines themselves.

If you can elaborate more on exectly the nature of your program, we might be better able to help.

Author Comment

ID: 33585826

Thanks for all the comments, i'm still thinking about all the
necessities to get this right. I'll possibly have to test/implement
several ways. If someone wants to give me or point me to
existing examples on how to interactively draw dwgs with excel
(including edits the next day) it definitely would help a lot.
I didn't really got to try much yet.

I'll give the points to ssaqibh or maybe i'll split them if i can get
sample files. We're using Acad2005.

Attaching xdata works well:
(setq lastent (entget (entlast)))
(regapp "NEWDATA")
(setq exdata '((-3 ("NEWDATA" (1000 . "This is a new thing!")))))
(setq newent (append lastent exdata))
(entmod newent)

Check for xdata:
(entget (car (entsel)) '("NEWDATA"))

LVL 11

Expert Comment

ID: 33593583
Can you post a sample drawing and/or sample Excel file that you think you might end up with?  Depending on what you're trying to do, some apporaches may work better than others.

If the Excel file is the template to create the entire drawing, I'd consider not editing the drawing at all, just erasing and redrawing in it's modified state if selection of items is cumbersome or difficult.

Author Comment

ID: 33612977

I'll definitely get back here in the next weeks and maybe
also post samples, all my drawings will need manual and
automated edits.

I have lots of other questions too then, thanks again for
all your comments.

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following article will describe how to add/edit a dimension style through AutoCAD VBA. AutoCAD VBA has its quirks and when it comes to dimensions and controlling how they look through VBA.  This is where AutoCAD can be vividly confusing. The…
This article will show, step by step, how to integrate R code into a R Sweave document
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question