AutoLISP problems with entities

Status
Not open for further replies.

Darius Blaszijk

Usenet Archive
Joined
Dec 24, 2001
Messages
5
Reaction score
0
Hi there,

Im having problems with extracting data from entities. I have drawn a rectangle in layer 0 and I want to extract the coordinates of the two diagonal corners. But somehow i cannot even get a linetype or whatever extracted. I think the problem is with the vertexes, although I'm not sure. Please help me out of this mess.

Kind regards, Darius Blaszijk

' this is what I have produced sofar

(setq lay_name "0")
(setq ss1
(ssget "X"
(list (cons 8 lay_name))
)
(setq a (assoc 100 ss1))
)
 
Darius Blaszijk schrieb:

Please help me out of this mess.

Kind regards, Darius Blaszijk

' this is what I have produced sofar ...

Sorry to have to say this, but you are dead wrong. I seriously recommend you to do an AutoLISP tutorial first before you start programming.

Here you get a function to extract the vertices from a LWPOLYLINE:

(defun pl-vertices (/ en el dxf vertexlist)
;; select an entity:
(setq en (car (entsel "\nSelect a polyline: ")))

;; get the entity list from the entity
(setq el (entget en))

;; print the object type:
(princ (strcat "\nobject type is: " (cdr (assoc 0 el))))

;; only if we have a LWPOLYLINE:
(if (= "LWPOLYLINE" (cdr (assoc 0 el)))
;; check all the dxf data for vertices (dxf group code 10)) ;; and collect the vertex coordinates in a vertexlist (foreach dxf el ;; only if group code is 10 (if (= 10 (car dxf)) (setq vertexlist (cons (cdr dxf) vertexlist)) ) )
)

;; make the function return the list of vertices
vertexlist
)

Tom Berger
 
Status
Not open for further replies.

Latest threads

Back
Top