Author Topic: Convert LWPOLYLINE into curve fitted and spline polyline  (Read 1943 times)

0 Members and 1 Guest are viewing this topic.

XXL66

  • Newt
  • Posts: 99
Convert LWPOLYLINE into curve fitted and spline polyline
« on: October 20, 2015, 09:18:20 AM »
hello,

i want to convert LWPOLYLINES and use the PEDIT command to turn them into curve fitted or spline poly's

using          (command   "_pedit" (list e pt) "_S" "_X") and (command   "_pedit" (list e pt) "_F" "_X")

however this does not seem to work consistently. Sometimes is works sometimes it doesn't and i cannot seem to find out why...

I get "Unable to recognize entry.  Please try again." This is in BCAD. However trying manually (reconstructing lisp entry) it seems to works fine...

Is there any other simple method for converting these polylines other then using PEDIT ?

ty !

roy_043

  • Water Moccasin
  • Posts: 1731
  • BricsCAD 18
Re: Convert LWPOLYLINE into curve fitted and spline polyline
« Reply #1 on: October 20, 2015, 09:48:02 AM »
For the command call to work I think the pt value must be a point on the entity.
Code - Auto/Visual Lisp: [Select]
  1. (command "_pedit" (list e (vlax-curve-getstartpoint e)) "_S" "_X")

Alternative approach:
Convert the polyline to a heavy polyline and change the type property.
Code for converting a polyline can be found here:
http://www.bricsys.com/common/support/forumthread.jsp?id=15124

There is also a _CONVERTPOLY command that can be used.

XXL66

  • Newt
  • Posts: 99
Re: Convert LWPOLYLINE into curve fitted and spline polyline
« Reply #2 on: October 21, 2015, 05:06:03 AM »
thx Roy,

unfortunally your suggestion does not help. I know it needs a pt on th entity, and this is the case.
it does a few lwpl's and then it stops and the wierd thing is that the last polyline has become "line" segments, no exploding is involved, just a loop for all LWPL's and PEDIT them...



XXL66

  • Newt
  • Posts: 99
Re: Convert LWPOLYLINE into curve fitted and spline polyline
« Reply #3 on: October 21, 2015, 05:44:23 AM »
If you execute it manually with pedit multiple select it also does not work correctly. In ACAD this works fine. I filed a support request at Bricsys.

roy_043

  • Water Moccasin
  • Posts: 1731
  • BricsCAD 18
Re: Convert LWPOLYLINE into curve fitted and spline polyline
« Reply #4 on: October 21, 2015, 08:38:02 AM »
... the wierd thing is that the last polyline has become "line" segments, no exploding is involved, just a loop for all LWPL's and PEDIT them...
I have yet to test your code in a loop. But the "_X" option may be the cause of the exploding you see.

roy_043

  • Water Moccasin
  • Posts: 1731
  • BricsCAD 18
Re: Convert LWPOLYLINE into curve fitted and spline polyline
« Reply #5 on: October 21, 2015, 10:12:45 AM »
After doing some more research I find that the problem occurs when you try to use the "_SPLINE" option on an LW polyline with only two vertices. I do not get this error with the "_FIT" option.

If your tests confirm this, it may be wise to add this information to your SR.

Code - Auto/Visual Lisp: [Select]
  1. (defun c:Test ( / ss)
  2.   (if
  3.     (and
  4.       (setq ss (ssget '((0 . "LWPOLYLINE"))))
  5.       (setq ss (vle-selectionset->list ss))
  6.     )
  7.     (foreach enme ss
  8.       (command "_.pedit" (list enme (vlax-curve-getstartpoint enme)) "_spline" "_exit")
  9.       (if (/= 0 (getvar 'cmdactive))
  10.         (progn
  11.           (setq *out* enme) ; Store enme as global variable.
  12.           (while (/= 0 (getvar 'cmdactive)) (command nil))
  13.         )
  14.       )
  15.     )
  16.   )
  17. )
  18.  
  19. (defun c:TestFix ( / ss)
  20.   (if
  21.     (and
  22.       (setq ss (ssget '((0 . "LWPOLYLINE") (-4 . ">") (90 . 2))))
  23.       (setq ss (vle-selectionset->list ss))
  24.     )
  25.     (foreach enme ss
  26.       (command "_.pedit" (list enme (vlax-curve-getstartpoint enme)) "_spline" "_exit")
  27.     )
  28.   )
  29. )
  30.  
  31. (defun c:TestFixAlt ( / ss)
  32.   (if (setq ss (ssget '((0 . "LWPOLYLINE"))))
  33.     (progn
  34.       (command "_.convertpoly" "_heavy" ss "")
  35.       (foreach obj (mapcar 'vlax-ename->vla-object (vle-selectionset->list (ssget "_P")))
  36.         (vla-put-type obj accubicsplinepoly)
  37.       )
  38.     )
  39.   )
  40. )

Test with PEDIT, the "_MULTIPLE" option and two LW polylines with 2 vertices:
Code: [Select]
: pe
Multiple/Select polyline to edit: m
Select entities:
Opposite Corner:
Entities in set: 2
Select entities:
Edit polyline:  Close/Open/Decurve/Fit/Join/Linetype-mode/Reverse/Spline/Taper/Width/Undo/<eXit>: s
Object of class AcDb2dPolyline can't be cast to AcDbPolyline.

XXL66

  • Newt
  • Posts: 99
Re: Convert LWPOLYLINE into curve fitted and spline polyline
« Reply #6 on: October 23, 2015, 02:25:16 AM »
Thx Roy,

indeed it has to do with 2 vertex polylines only. They are aware of the problem and also suggested the work-around with convertpoly.

thanks again !