Fatima
Fatima

Reputation: 869

Why the entnext command returns nil?

I am pretty new to AutoLISP and also AutoCAD.

I want to get the vertices of a polyline, so that I can change their widths.

Here is a piece of code I have written. I want to know why it doesn't work. The "entnext" part seems to cause the problem. It returns nil value when I test it with "!".

  (setq e(entget (car (entsel))))
  (setq e1(entget (entnext(cdr(car e)))))

I will appreciate any help or clue to get this solved.

Upvotes: 0

Views: 1098

Answers (1)

Matus
Matus

Reputation: 437

first: you can simplify your code to (setq e1(entget(entnext(car(entsel)))))

because you set e to the listing of selected entity and then take the entity name from that list (cdr (car e)), but that's what you already had (car (entsel))

second: there are two types of polylines in AutoCAD, one is LWPOLYLINE:

((-1 . <Entity name: 7ffff6051c0>) (0 . "LWPOLYLINE") (330 . 
<Entity name: 7ffff603f50>) (5 . "94") (100 . "AcDbEntity") (67 . 0) (410 . 
"Model") (8 . "0") (100 . "AcDbPolyline") (90 . 7) (70 . 0) (43 . 0.0) (38 . 
0.0) (39 . 0.0) (10 130.547 84.582) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) 
(10 194.681 129.062) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (10 239.54 
77.9275) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (10 311.035 131.864) (40 . 
0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (10 388.487 66.0195) (40 . 0.0) (41 . 0.0) 
(42 . 0.0) (91 . 0) (10 445.962 135.366) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 
0) (10 500.634 73.3744) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (210 0.0 0.0 
1.0))

and the other is POLYLINE:

((-1 . <Entity name: 7ffff605220>) (0 . "POLYLINE") (330 . 
<Entity name: 7ffff603f50>) (5 . "9A") (100 . "AcDbEntity") (67 . 0) (410 . 
"Model") (8 . "0") (100 . "AcDb3dPolyline") (66 . 1) (10 0.0 0.0 0.0) (70 . 8) 
(40 . 0.0) (41 . 0.0) (210 0.0 0.0 1.0) (71 . 0) (72 . 0) (73 . 0) (74 . 0) (75 
. 0))

to get vertices of LWPOLYLINE, you have to pick DXF codes 10 from the listing, with POLYLINE, which is used to represent 3d polyline, you can use your code

Upvotes: 1

Related Questions