Data Extraction to AutoLISP

Data Extraction to AutoLISP

Anonymous
Not applicable
1,386 Views
11 Replies
Message 1 of 12

Data Extraction to AutoLISP

Anonymous
Not applicable

Hi everyone,

 

Does anyone now how to automatically extract all the shapes (e.g. arcs, circles and lines) of an AutoCAD file to an AutoLISP file?

I want that the generated AutoLISP file, when executed, is able to reproduce the input shapes.

 

Thanks in advance,

Sara

0 Likes
1,387 Views
11 Replies
Replies (11)
Message 2 of 12

rkmcswain
Mentor
Mentor

So you have a drawing that contains arcs, circles, lines, polylines, text, etc.

And you want a lisp file that will capture all of that geometry and be able to reproduce it all in another drawing?

R.K. McSwain     | CADpanacea | on twitter
0 Likes
Message 3 of 12

Anonymous
Not applicable

Exactly!

0 Likes
Message 4 of 12

cadffm
Consultant
Consultant

Yes i know such a functions, pretty easy to write for simple object (for a circle you need the entitylist and the layer entity list, nothing more)

and for more complex objects and annotative stuff you have to think about more things.

But: Why not using a DWG?

Simple to handle, simple to edit,

usual workflow (insert file as block).

 

 

Sebastian

0 Likes
Message 5 of 12

rkmcswain
Mentor
Mentor
Or DXF if open access to the data is a problem.
R.K. McSwain     | CADpanacea | on twitter
0 Likes
Message 6 of 12

Sea-Haven
Mentor
Mentor

Use wblock that's what its for.

0 Likes
Message 7 of 12

Anonymous
Not applicable

Thank you for your replies.

 

However, I am only interested in converting geometry to code.

So, lets say I have 3 circles in my CAD drawing and I want to extract them to an AutoLISP file, as following:

 

(command "circle" "0,0" "3")
(command "circle" "0,0" "2")
(command "circle" "0,0" "1")

 

What would be the lisp routine to do that?

 

Thanks again, Sara

0 Likes
Message 8 of 12

cadffm
Consultant
Consultant

@Anonymous  schrieb:

(command "circle" "0,0" "3")
(command "circle" "0,0" "2")
(command "circle" "0,0" "1")

 

What would be the lisp routine to do that?


 

Sorry, that not code, thats only a kind of Script.

Answer: Impossible, or you have to do much work for "all possible geometrie objects".

And: I don't know about such a program (because of WHY should someone write a prog like this?),

but you can try to write your own for some or many cases it will work.

 

 

This is what i understand as Code (just a simple sample):

Draw a Circle, on Layer0

Use this:

Command: (setq ELI (entget (car(entsel))))

 

The code to create a object like this: (entmake ELI)

 

 

This shows the object data:

Command: (foreach dp ELI (print dp))

 

 

If the Layer is not 0, think about you programm have to copy the Layerdefinition too

and by re-creating: First make sure the layer exists or you have to re-create the Layer,

and so on.

Sebastian

0 Likes
Message 9 of 12

pbejse
Mentor
Mentor

What are you going to use it for?

 

0 Likes
Message 10 of 12

Anonymous
Not applicable

Why? I may want to make changes in the code. But at this point, this is merely an academic question.

 

I just want a mechanism to automatically generate an AutoLISP program which represents all the geometry in a CAD tool. The resulting program must be written in the same way as I was writing it from scratch.

 

As far as I'm concerned, (entget (car (entsel)))  extracts only one entity at a time...

0 Likes
Message 11 of 12

pbejse
Mentor
Mentor

@Anonymous wrote:

Why? I may want to make changes in the code. But at this point, this is merely an academic question.

 

I just want a mechanism to automatically generate an AutoLISP program which represents all the geometry in a CAD tool. The resulting program must be written in the same way as I was writing it from scratch.

 


What you need is not a mutable progam, but one that reads a data in a form of a list that one immutabgle program reads and stores the info, it  could very well be an external file.

 


@Anonymous wrote:

As far as I'm concerned, (entget (car (entsel)))  extracts only one entity at a time...


What you're looking for is the function ssget , ssname , entget and while or repeat 

 

 

0 Likes
Message 12 of 12

diagodose2009
Collaborator
Collaborator

My Chrome, reject me , and I can not send PM to you.

Please ,  I understand your question, for more details, then...

You  make user account on the forum and you send PM to "Zauchan-user,".He can try help you..

 

You found link-bellow. 

 

0 Likes