Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Entmake "Two vertices were added to a 2D pline (0) which had no vertices."

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
Anonymous
2018 Views, 8 Replies

Entmake "Two vertices were added to a 2D pline (0) which had no vertices."

I am making points, lines fine with entmake, but with lwpolylines I am getting an error message for each entitiy:

"Two vertices were added to a 2D pline (0) which had no vertices."

 

To try and make a donut:

 

        (entmake (list '(0 . "LWPOLYLINE") (cons 8 lyr) '(90 . 2) '(70 . 1) (cons 43 cwid)

           (cons 100 "AcDbEntity") (cons 100 "AcDbPolyline")
           (list 10 x1 0.0) '(41 . 1.0)
           (list 10 x2 0.0) '(41 . 1.0) ))

 

Result is:

 

((-1 . <Entity name: 7d8b9990>) (0 . "LWPOLYLINE") (330 . <Entity name:
7eeaecf8>) (5 . "F7F2") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 .
"aka_pts2") (100 . "AcDbPolyline") (90 . 2) (70 . 0) (43 . 0.0) (38 . 0.0) (39
. 0.0) (10 0.0 0.0) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (10 0.0 0.0) (40
. 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (210 0.0 0.0 1.0))

 

DXF codes 70, 10, 43 are all set to zero, not what I passed to the entmake function.  This entity has a name, but is not visible as an entity in the drawing.

 

To try and make a 3-sided closed lwpolyline:

 

        (entmake (list

           '(0 . "LWPOLYLINE")  '(8 . "fix_pts") '(90 . 4) '(70 . 1) '(43 . 20)

           (cons 100 "AcDbEntity") (cons 100 "AcDbPolyline") 

           (list 10 x1 y1)
           (list 10 x2 y2)
           (list 10 x3 y3)     ) )

 

Result is

 

((-1 . <Entity name: 7d2165b8>) (0 . "LWPOLYLINE") (330 . <Entity name:
7eeaecf8>) (5 . "10F67") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 .
"fix_pts") (100 . "AcDbPolyline") (90 . 2) (70 . 0) (43 . 0.0) (38 . 0.0) (39 .
0.0) (10 0.0 0.0) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (10 0.0 0.0) (40 .
0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (210 0.0 0.0 1.0))

 

Seems like the same problem.  I did try entmakex in conjunction with dictadd.  Same results there.  Google not much help.  I need an interpreter to explain the meaning of that error message and what is wrong with my code.

 

8 REPLIES 8
Message 2 of 9
stevor
in reply to: Anonymous

1. Try the cons function instead of list or ' functions: (cons 10 (list x1 0 0)) (cons 41 1.0) for: (list 10 x1 0.0) '(41 . 1.0) 2. Make sure the variable have numeric values, for x1, etc,
S
Message 3 of 9
Kent1Cooper
in reply to: Anonymous

Could the donut problem be that your (assoc) code number for the bulge factor is incorrect?  40 & 41 are the starting and ending widths; 42 is the bulge factor that would be 1 for a donut.  Your 41 may conflict with your 43 [global width].

 

But the other construction doesn't involve arc segments, so maybe that's not the only problem.  Are you in Model Space when you do it?  The results are going there, but you're not specifying that in your lists.  Is the Layer on and thawed?  Are the points within the current view?

Kent Cooper, AIA
Message 4 of 9
Anonymous
in reply to: Anonymous

Thanks for the good suggestions from the last 2 posts.   I got it to work.

 

I think the thing that changed it was to specify model space.  In truth, I ended up specifying all required and optional elements and arranging them in the order displayed by entget.

 

Dennis McKay, Santa Fe

Message 5 of 9
Kent1Cooper
in reply to: Anonymous


@Anonymous wrote:

.... In truth, I ended up specifying all required and optional elements and arranging them in the order displayed by entget.

....


That's exactly why I don't usually use (entmake) unless one of the reasons it's necessary [in a reactor, for instance] holds.  This will result in exactly the same thing, except that if you're in paper space or some non-world Coordinate System at the time you run it, you would need to add a switch-over if you want the donut in model space and in World Coordinates:

 

(command

  "_.layer" "_s" lyr ""

  "_.pline" "non" (list x1 0) "_w" cwid "" "_a" "_d" "90" "non" (list x2 0) "_cl"

  "_.layerp"

)

 

or if you prefer to use the actual Donut command, since that's what you're making:

 

(command

  "_.layer" "_s" lyr ""

  "_.donut" (- (abs (- x2 x1)) cwid) (+ (abs (- x2 x1)) cwid) "non" (list (/ (+ x1 x2) 2.0) 0) ""

  "_.layerp"

)

Kent Cooper, AIA
Message 6 of 9
Anonymous
in reply to: Anonymous

 I have loads of experience using the command function.  My problem with the program in question was performance.  A lot of time is taken up with rebuilding screen graphics and text output.  By replacing my old code with the entmake code, I was able to get the program to run 12 times as fast on a small dataset and 5 times as fast on a typical large dataset (old code took over 13 mins to complete, now 2.5 mins).  This is enough to make this program desirable.  My vanity is at stake here because I am just about to share this program with my colleagues.

I am pleased to get entmake to work and use it exclusively in the future. I very much appreciate your help this week (and last week too).  I and my cohorts always work in model space and in 2D.  I have never investigated views/viewports, so those are not a problem for my usage of entmake.

A mystery still remains.  The entupd command requires an entity name and the entmake command does not supply it.  I tried getting the name through entlast but the entmake entity is not yet in the drawing database.  I used entmakex with no change in effect.  I do notice that the screen remains unchanged thoughout the program until it pops up full at the very end.  Even print and prin1 messages to assuage the user and advise patience does not even appear.  I tried the regen command at a few junctures in the program to give the user some indication that the program is working, but it had no effect.  It would add polish to the program if I could resolve this.

Message 7 of 9
Kent1Cooper
in reply to: Anonymous


@Anonymous wrote:

....  By replacing my old code with the entmake code, I was able to get the program to run 12 times as fast on a small dataset and 5 times as fast on a typical large dataset (old code took over 13 mins to complete, now 2.5 mins).  ....  A mystery still remains.  The entupd command requires an entity name and the entmake command does not supply it.  ....


Well, having large amounts of things to process is certainly another of the worthy reasons for choosing (entmake) over (command).

 

But I can't help you with the remaining mystery, since I so seldom work with (entmake).  But I wonder whether (redraw) without the entity-name argument might possibly do it for you.

Kent Cooper, AIA
Message 8 of 9
Anonymous
in reply to: Anonymous

REDRAW does work.  Thanks yet again.

Message 9 of 9
CADaSchtroumpf
in reply to: Anonymous

Hi,

 

This code convert a circle to a donut. If can help you for adjust your code....

 

 

(defun c:circle2lw ( / js ent dxf_ent pt_cen radius fst_pt opp_pt new_ep)
  (princ "\nSelect a circle to be converted into a donut: ")
  (while (null (setq js (ssget "_:S" '((0 . "CIRCLE"))))))
  (setq
    ent (ssname js 0)
    dxf_ent (entget ent)
    pt_cen (cdr (assoc 10 dxf_ent))
    radius (cdr (assoc 40 dxf_ent))
    fst_pt (polar pt_cen 0.0 radius)
    opp_pt (polar pt_cen pi radius)
  )
  (princ "\nThickness of donut <")
  (princ (getvar "PLINEWID"))
  (princ ">: ")
  (initget 68)
  (setq new_ep (getdist))
  (if new_ep (setvar "PLINEWID" new_ep))
  (entmake
    (list
      '(0 . "LWPOLYLINE")
      '(100 . "AcDbEntity")
      (assoc 67 dxf_ent)
      (assoc 410 dxf_ent)
      (assoc 8 dxf_ent)
      (if (assoc 6 dxf_ent) (assoc 6 dxf_ent) '(6 . "BYLAYER"))
      (if (assoc 62 dxf_ent) (assoc 62 dxf_ent) '(62 . 256))
      (if (assoc 370 dxf_ent) (assoc 370 dxf_ent) '(370 . -3))
      (if (assoc 48 dxf_ent) (assoc 48 dxf_ent) '(48 . 1.0))
      '(100 . "AcDbPolyline")
      '(90 . 2)
      '(70 . 1)
      (cons 43 (getvar "PLINEWID"))
      (cons 38 (caddr pt_cen))
      (if (assoc 39 dxf_ent) (assoc 39 dxf_ent) '(39 . 0.0))
      (cons 10 (list (car fst_pt) (cadr fst_pt)))
      '(40 . 0.0)
      '(41 . 0.0)
      '(42 . 1.0)
      (cons 10 (list (car opp_pt) (cadr opp_pt)))
      '(40 . 0.0)
      '(41 . 0.0)
      '(42 . 1.0)
      (assoc 210 dxf_ent)
    )
  )
  (entdel ent)
  (prin1)
)

 

 

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost