Tenha uma nova experiência ao navegar no Fórum pelo computador de forma integrada ao portal principal. Acesse o seguinte link: https://www.autolisp.com.br/board/. Entretanto para dispositivos móveis recomendamos acessar este outro link: https://www.autolisp.com.br/forum/

Conversão de Arcos em plines

Dúvidas sobre AutoLISP...

Moderador: Moderadores

Responder
edu200713
Novato
Novato
Mensagens: 2
Registrado em: Qua 04 Mar 2020 8:51:27 am

Conversão de Arcos em plines

Mensagem por edu200713 » Qua 04 Mar 2020 8:57:26 am

Bom dia

Existe uma forma de converter arco para segmentos de retas?
É que tenho vários arcos e preciso que estes passem para segmentos lineares (plines).

Avatar do usuário
Carlos Fernando
Madeira
Madeira
Mensagens: 16
Registrado em: Sex 29 Dez 2017 4:17:25 pm

Re: Conversão de Arcos em plines

Mensagem por Carlos Fernando » Qua 04 Mar 2020 9:22:56 pm

Boa noite
Veja uma discussão sobre isso nesse link:
https://forums.autodesk.com/t5/visual-l ... -p/8054880

A lisp wobblypline fornecida por um usuário parece resolver seu problema, eu testei na opção "arco" e funcionou.
É claro que a precisão para converter um segmento curvilineo em trechos retos depende da quantidade de trechos retos que
vc especificar, ou seja, quanto mais trechos melhor será a aproximação.
Caso não consiga baixar a lisp eu a reproduzo abaixo.


Autor Kent Cooper, October 2008

Código: Selecionar todos

;;;  WobblyPline.LSP [Command name: WPL]
;;;  To draw a Polyline that wobbles "randomly" from the plain path created or selected.
;;;  Options:
;;;    1.  create new, or select EXisting, path of any appropriate type;
;;;    2.  number of line segments in resulting polyline;
;;;    3.  degree of randomization [as a percentage of average segment length];
;;;    4.  after first use, re-use PRevious path [changing any or all choices], or
;;;    5.  after first use, Redo wholesale, using previous path and all previous choices;
;;;    6.  Retain or Delete base path.
;;;  Under Existing-path option, asks User to select again if nothing selected, or selected object
;;;    is an inappropriate entity type, or is on a locked Layer under Delete-path option.
;;;  Draws 3DPolyline [randomized only in X-Y direction] if path is one; otherwise draws 2D
;;;    ["lightweight"] Pline.
;;;  Draws on current Layer, unless Deleting Existing path; if so, draws on its Layer.
;;;  Remembers choices and offers them as defaults for subsequent use.
;;;
;;;  Kent Cooper, October 2008
;
(defun C:WPL (/ *error* cmde osm typetemp pathsel deltemp 3Dpath segtemp pcttemp
  segavg maxdis intpt blips base angdisp distdisp)
;
  (defun *error* (errmsg)
    (if (/= errmsg "Function cancelled") (princ (strcat "\nError: " errmsg)))
    (setvar 'osmode osm)
    (setvar 'blipmode blips)
    (command "_.undo" "_end")
    (setvar 'cmdecho cmde)
  ); end defun *error*
;
  (setq cmde (getvar 'cmdecho))
  (setvar 'cmdecho 0)
  (command "_.undo" "_begin")
  (setq
    blips (getvar 'blipmode)
    osm (getvar 'osmode)
  ); end setq
  (setvar 'osmode 0)
;
  (if *wpl*
    (initget "Line Arc Circle Pline 3dpoly Ellipse Spline EXisting PRevious Redo")
    (initget "Line Arc Circle Pline 3dpoly Ellipse Spline EXisting"); no PR/R options on first use
  ); end if
  (setq typetemp
    (getkword
      (strcat
        "\nPath type [new Line(single)/Arc/Circle/Pline(2D)/3dpoly/Spline/Ellipse, or EXisting"
        (if *wpl*
          "/PRevious/Redo"
          ""
        ); end if
        "] <"
        (if *wpl* *wpltype* "Pline"); at first use, Polyline default; otherwise, previous type
        ">: "
      ); end strcat
    ); end getkword
    *wpltype*
      (cond
        (typetemp); if User typed something other than Enter, use it
        (*wpltype*); if Enter and there's a previous type, use that
        (T "Pline"); otherwise [Enter on first use], Polyline default
      ); end cond & *wpltype*
  ); end setq
;
  (if (= *wpltype* "PRevious") (entdel *wpl*)); if re-using Previous path with option
    ;  of new choices [but not wholesale Redo], delete previous wobbly Polyline
  (if (and (= *wpltype* "PRevious") (= *wpldel* "Delete")) (entdel *wplpath*)); bring back Previous path
;
  (if (/= *wpltype* "Redo"); if not Redoing,
    (progn
      (initget "Retain Delete")
      (setq
        deltemp
          (getkword
            (strcat
              "\nRetain or Delete base path [R/D] <"
              (if *wpl* (substr *wpldel* 1 1) "D"); at first use, Delete default; otherwise, previous type
              ">: "
            ); end strcat
          ); end getkword
        *wpldel*
          (cond
            (deltemp); if User typed something, use it
            (*wpldel*); if Enter and there's a previous choice, use that
            (T "Delete"); otherwise [Enter on first use], Delete
          ); end cond & *wpldel*
      ); end setq
    ); end progn
  ); end if
;
  (cond ; select or make path
    ((and (= *wpltype* "EXisting") (= *wpldel* "Delete")); check selected object for locked Layer if Delete option
      (prompt "\nTo make an EXisting path wobbly,")
      (while
        (not
          (and
            (setq pathsel (ssget ":S" '((0 . "LINE,ARC,CIRCLE,LWPOLYLINE,POLYLINE,ELLIPSE,SPLINE"))))
            (= (cdr (assoc 70 (tblsearch "layer" (cdr (assoc 8 (entget (ssname pathsel 0))))))) 0); 0 for Unlocked, 4 for Locked
          ); end and
        ); end not
        (prompt "\nNothing selected, or object is not a finite path type, or is on a Locked Layer; try again:")
      ); end while
    ); end first condition - EXisting with Delete
    ((= *wpltype* "EXisting")
      (prompt "\nTo make an EXisting path wobbly,")
      (while
        (not (setq pathsel (ssget ":S" '((0 . "LINE,ARC,CIRCLE,LWPOLYLINE,POLYLINE,ELLIPSE,SPLINE")))))
        (prompt "\nNothing selected, or object is not a finite path type; try again:")
      ); end while
    ); end second condition - EXisting with Retain
    ((and (= *wpltype* "Redo") (= *wpldel* "Delete")) (entdel *wplpath*)); bring back path
    ((= *wpltype* "Line") (setvar 'cmdecho 1) (command "_.line" pause pause "") (setvar 'cmdecho 0))
    ((not (or (= *wpltype* "Redo") (= *wpltype* "PRevious"))); all other entity types
      (setvar 'cmdecho 1)
      (command *wpltype*)
      (while (> (getvar 'cmdactive) 0) (command pause))
      (setvar 'cmdecho 0)
    ); end fourth condition
  ); end cond
;
  (setq
    *wplpath* ; set object as base path
      (cond
        ((= *wpltype* "EXisting") (ssname pathsel 0))
        ((or (= *wpltype* "Redo") (= *wpltype* "PRevious")) *wplpath*)
        ((entlast)); newly created path
      ); end cond & *wplpath*
    pathlength (vlax-curve-getDistAtParam *wplpath* (vlax-curve-getEndParam *wplpath*))
    3Dpath (= (cdr (assoc 0 (entget *wplpath*))) "POLYLINE")
  ); end setq
;
  (if (/= *wpltype* "Redo"); if not Redoing,
    (progn ; then - ask for other input
;
      (if *wpl* (initget 6) (initget 7)); no Enter on first use, no 0, no negative
      (setq
        segtemp
          (getint
            (strcat
              "\nNumber of segments"
              (if *wplseg* (strcat " <" (itoa *wplseg*) ">") ""); no default on first use
              ": "
            ); end strcat
          ); end getint
        *wplseg* (if segtemp segtemp *wplseg*)
      ); end setq
;
      (if *wplpct* (initget 4) (initget 5)); no Enter on first use, 0 allowed, no negative
      (setq
        pcttemp
          (getreal
            (strcat
              "\nMaximum displacement as percentage of average segment length"
              (if *wplpct* (strcat " <" (rtos *wplpct* 2 2) ">") ""); no default on first use
              ": "
            ); end strcat
          ); end getreal
        *wplpct* (if pcttemp pcttemp *wplpct*)
      ); end setq
;
    ); end progn - not Redoing
    (entdel *wpl*); else - if Redoing, eliminate previous one
  ); end if
;
  (setq
    segavg (/ pathlength *wplseg*)
    maxdis (* segavg *wplpct* 0.01); maximum displacement
    intpt 1 ; starting value for intermediate point
  ); end setq
  (setvar 'blipmode 0)
;
  (if (not 3Dpath) (command "_.ucs" "_new" "_object" *wplpath*)) ; set UCS to match object if appropriate
  (if (= *wpldel* "Delete") (setvar 'clayer (cdr (assoc 8 (entget *wplpath*))))) ; if Deleting Existing path, draw on same Layer
;
  (command
    (if 3Dpath "3dpoly" "_.pline"); command type - Pline for all but 3D Polylines
    (trans (vlax-curve-getStartPoint *wplpath*) 0 1)
    (while (< intpt *wplseg*)
      (setq
        base (vlax-curve-getPointAtDist *wplpath* (* segavg intpt)); un-randomized intermediate location
        angdisp (* 2 pi (/ (atoi (substr (rtos (rem (getvar 'cdate) 1) 2 16) (- 17 (fix (rem (cadr base) 3)) (fix (abs (* (sin intpt) 10)))) 2)) 100.0))
          ; randomized angle
        distdisp (* maxdis (/ (atoi (substr (rtos (rem (getvar 'date) 1) 2 16) (- 18 (rem (fix (sqrt (abs (car base)))) 5) (rem intpt 3)) 2)) 100.0))
          ; randomized distance
        intpt (1+ intpt); increment intermediate point number
      ); end setq
      (command (polar (trans base 0 1) angdisp distdisp)); feed randomized location out to Pline or 3dpoly command
      (if (vlax-curve-isClosed *wplpath*)
        "_close"
        (trans (vlax-curve-getEndPoint *wplpath*) 0 1); last point for open path
      ); end if
    ); end while
    (if (not (vlax-curve-isClosed *wplpath*)) ""); end Pline or 3dpoly for open path
  ); end command - pline or 3dpoly
;
  (if (not 3Dpath) (command "_.ucs" "_prev")); reset UCS if appropriate
  (if (and (or (= *wpltype* "EXisting") (= *wpltype* "PRevious") (= *wpltype* "Redo")) (= *wpldel* "Delete")) (command "_.layerp"))
    ; reset Layer if appropriate
;
  (if (= *wpldel* "Delete") (entdel *wplpath*))
  (setq *wpl* (entlast))
  (setvar 'osmode osm)
  (setvar 'blipmode blips)
  (command "_.undo" "_end")
  (setvar 'cmdecho cmde)
  (princ)
); end defun
(prompt "Type WPL to make a Wobbly PolyLine.")
Abraço

edu200713
Novato
Novato
Mensagens: 2
Registrado em: Qua 04 Mar 2020 8:51:27 am

Re: Conversão de Arcos em plines

Mensagem por edu200713 » Qua 11 Mar 2020 8:58:21 am

Muito obrigado, resolveu o meu problema

Responder