• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

coordinated extraction of lines

  • Thread starter Thread starter som
  • Start date Start date

som

Guest
Bye to all,

I am very unexperienced with autocad and I am trying these days with programming with scripts and lisp.

My difficulty is to extract from a dwg a variable area which is bounded by some lines that reside in a specified layer.

how can I after selecting the objects of my interest proceed to evaluate their coordinates so as to deduce the window to me useful?



_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
|
|
|
|
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

I would like to have the coordinates of the 4 lines placed as above.

for now I can select :p

Thank you.
 
scripts and lisp are input for autocad, not output. If that's not how someone forgets me.

I would export a dxf. as the header of x and y is always the same, for any entity, it should be easy to extract all x, all y, find the minimum and maximum, and these four values are the coordinates of the vertices of a rectangle that circumscribes all the design.

This is true except for arches, so they should be filtered...but it is a next step.
 
the code finds the tops (left lower and upper right) of the maximum window that contains the objects in case I had solo lines, or your case:
HTML:
 (setq to 0)
(setq cont 0) ;azzera il contatore
(setq b (ssget))
(repeat (sslength b) ;ripete per il numero degli elementi selezionati
(setq c (ssname b cont))
(setq p1 (cdr (assoc 10 (entget c)))) ;punto iniale linea
(setq p2 (cdr (assoc 11)) ;punto iniale linea

(if (= a 0)
(progn)
(setq xmin (car p1))
(setq xmax (car p1)
(setq ymin (cadr p1))
(setq ymax (cadr p1))

(setq xmin (min xmin (car p2)))
(setq xmax (max xmax (car p2)))
(setq ymin (min ymin (cadr p2)))
(setq ymax (max ymax (cadr p2)))
)
)

(setq xmin (min xmin (car p1))
(setq xmax (max xmax (car p1))
(setq ymin (min ymin (cadr p1))
(setq ymax (max ymax (cadr p1))

(setq xmin (min xmin (car p2)))
(setq xmax (max xmax (car p2)))
(setq ymin (min ymin (cadr p2)))
(setq ymax (max ymax (cadr p2)))

(setq to nil)
(setq cont (1+ cont))

)

(setq p3 (list xmin ymin) ;punto inferiore sinistro
(setq p4 (list xmax ymax) ;punto superiore destro
 
thanks to both for the help.

@fulvio:
I'd rather work directly on the dwg.

@gp:
the layer that must indicate the content to use has only lines.. So the code you posted should do to my case... Now I'm verifying.

Thanks again.
 
selections of entities
(setq listent (ssget))

name entity n° 1
(setq n (ssname listent 0)

name entity n° 2
(setq n (ssname listent 1))

etc.

get list
(setq ent)

initial coordination
(setq pt1 (cdr 10 ent)))

final coordination
(setq pt2 (cdr 11 ent)))

Good job
 
......
(setq c (ssname b cont))
(setq p1 (cdr) (assoc 10 (entget c)))) ; indirect point
(setq p2 (cdr) (assoc 11 (entget c)))) ; indirect point
(if (= to 0)
......
I wrote in a hurry:redface:, but it was understood anyway. . .

......
(setq c (ssname b cont))
(setq p1 (cdr 10 (entget c))));Ziale line
(setq p2 (cdr) (assoc 11 (entget c))); fonline
(if (= to 0)
......
 

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

No members online now.
Back
Top