[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 726
  • Last Modified:

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


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
kiggsondrome
Asked:
kiggsondrome
  • 5
  • 4
  • 2
  • +1
1 Solution
 
Saqib Husain, SyedEngineerCommented:
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
 
kiggsondromeAuthor Commented:

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
 
Saqib Husain, SyedEngineerCommented:
Can you write the generated handles to a text file and, once completed, import the text file to excel?
0
New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

 
kiggsondromeAuthor Commented:

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
 
Saqib Husain, SyedEngineerCommented:
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
 
kiggsondromeAuthor Commented:

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
 
Saqib Husain, SyedEngineerCommented:
0
 
borgunitCommented:
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
 
darrenmcwiCommented:
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
 
kiggsondromeAuthor Commented:

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
 
darrenmcwiCommented:
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
 
kiggsondromeAuthor Commented:

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

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 5
  • 4
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now