Solved

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

Posted on 2010-08-26
12
682 Views
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?
0
Comment
Question by:kiggsondrome
  • 5
  • 4
  • 2
  • +1
12 Comments
 
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"

Saqib
0
 

Author Comment

by:kiggsondrome
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?
0
 
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?
0
 

Author Comment

by:kiggsondrome
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.

0
 
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?
0
 

Author Comment

by:kiggsondrome
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.  
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 500 total points
ID: 33539982
0
 
LVL 10

Expert Comment

by:borgunit
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.
0
 
LVL 11

Expert Comment

by:darrenmcwi
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.
0
 

Author Comment

by:kiggsondrome
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"))

0
 
LVL 11

Expert Comment

by:darrenmcwi
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.
0
 

Author Comment

by:kiggsondrome
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.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction This tutorial will give you a fast look what you can do with WhizBase. I expect you already know how to work with HTML at least, and that you understand the basics of the internet and how the internet works. WhizBase is a server-s…
This tutorial will discuss the log-in process using WhizBase. In this article I assume you already know HTML. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you might look at some of my other articles abo…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now