Author Topic: can you fix this lsp ( slice solid with polyline)  (Read 4213 times)

0 Members and 1 Guest are viewing this topic.

dussla

  • Bull Frog
  • Posts: 286
can you fix this lsp ( slice solid with polyline)
« on: January 09, 2009, 06:30:26 AM »
this is  slice soild with polyline by russian cool man
but that didn;t work well
pls , fix them


;; local defuns
;; groupping the list
(defun group-by-num  (lst num / ls ret)
  (if (= (rem (length lst) num) 0)
    (progn
      (setq ls nil)
      (repeat (/ (length lst) num)
  (repeat  num
    (setq  ls
        (cons (car lst) ls)
    lst (cdr lst)))
  (setq ret (append ret (list (reverse ls)))
        ls  nil)))
    )
  ret
  )

;get polyline vertices

(defun get-vexs   (pline_obj / verts)
  (setq  verts (vlax-get pline_obj 'Coordinates)
  verts
        (cond
    ((wcmatch (vlax-get pline_obj 'Objectname)
        "AcDb2dPolyline,AcDb3dPolyline")
     (group-by-num verts 3)
     )
    ((eq (vlax-get pline_obj 'Objectname)
         "AcDbPolyline")
     (group-by-num verts 2)
     )
    (T nil)
    )
  )
  )
(vl-load-com)
;;main part
(defun C:SSP  (/ *error* acsp adoc con osmd sscon sspline vertices_list)

  (defun *error* (msg)
    (cond
      ((not msg))
      ((wcmatch (strcase msg) "*QUIT*,*CANCEL*"))
      (T (princ (strcat "\nError: " msg)))
    )
  (if osmd   (setvar "osmode" osmd))
  (vl-cmdf "ucs" "w")
  (vl-cmdf "-view" "swiso")
  (vla-regen adoc acactiveviewport)
  (vla-endundomark adoc)
    (princ)
  )

  (setq  adoc (vla-get-activedocument
         (vlax-get-acad-object)
         )
  acsp (vla-get-block
         (vla-get-activelayout adoc)
         )
  )
  (vla-startundomark adoc)
  (vl-cmdf "ucs" "w")

  (setq osmd (getvar "osmode"))
  (setvar "osmode" 0)
  (alert "\nSelect the solid first\nthan select the polyline")
  (if (and
  (setq sscon (ssget "+.:S:N" (list (cons 0 "3DSOLID"))))
  (setq sspline (ssget "+.:S:N" (list (cons 0 "POLYLINE")))))
    (progn
      (setq vertices_list
       (get-vexs
         (vlax-ename->vla-object
     (ssname sspline 0))))
      (vl-cmdf "slice" (ssname sscon 0) "" "3P" (trans (car vertices_list) 1 0)
         (trans (cadr vertices_list) 1 0)
         (trans (caddr vertices_list) 1 0)
         '(0. 0. -100000.));;<-- change on '(0. 0. 100000.) if you need to keep the upper section

      ))

  (alert "Delete unused section\n of sliced solid manually")
  (*error* nil)
  (princ)
  )
(prompt "\n=======================================================\n")
(prompt "\n\t\t***\tStart command with SSP\t***")
(prompt "\n=======================================================\n")
(prin1)

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: can you fix this lsp ( slice solid with polyline)
« Reply #1 on: January 09, 2009, 05:01:33 PM »
It is necessary to specify the author! The author is known at this forum...
fixo

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: can you fix this lsp ( slice solid with polyline)
« Reply #2 on: January 10, 2009, 08:25:57 PM »
Thanks for the 'Heads Up' Evgeniy.

Doing a search on the net and the usual places I see Fixo I have not been able to find the original routine.
I was going to add a link to the routine.
« Last Edit: January 10, 2009, 08:33:19 PM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Crank

  • Water Moccasin
  • Posts: 1503
Re: can you fix this lsp ( slice solid with polyline)
« Reply #3 on: January 11, 2009, 01:37:05 AM »
[...]
I was going to add a link to the routine.
Here it is.
Vault Professional 2023     +     AEC Collection

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: can you fix this lsp ( slice solid with polyline)
« Reply #4 on: January 11, 2009, 02:35:47 AM »
original routine
anycg = dussla

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: can you fix this lsp ( slice solid with polyline)
« Reply #5 on: January 11, 2009, 07:29:14 AM »
Thanks for the help fellas.  8-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

dussla

  • Bull Frog
  • Posts: 286
Re: can you fix this lsp ( slice solid with polyline)
« Reply #6 on: January 16, 2009, 03:58:15 AM »
i tested this lisp  , but still didn;t work ~

pls can you test ?

fixo

  • Guest
Re: can you fix this lsp ( slice solid with polyline)
« Reply #7 on: January 19, 2009, 04:56:17 AM »
i tested this lisp  , but still didn;t work ~

pls can you test ?
Your drawing is wrong
I got the following error message:
"Slicing plane does not intersect the selected solid"
So, you need first to change elevation proprty of the slicing polyline:
go to Properties dialog box and change elevation on 36.0
then run the edited version
Code: [Select]
;; local defuns
;; groupping the list
(defun group-by-num  (lst num / ls ret)
  (if (= (rem (length lst) num) 0)
    (progn
      (setq ls nil)
      (repeat (/ (length lst) num)
  (repeat  num
    (setq  ls
        (cons (car lst) ls)
    lst (cdr lst)))
  (setq ret (append ret (list (reverse ls)))
        ls  nil)))
    )
  ret
  )

;get polyline vertices

(defun get-vexs   (pline_obj / verts)
  (setq  verts (vlax-get pline_obj 'Coordinates)
  verts
        (cond
    ((wcmatch (vlax-get pline_obj 'Objectname)
        "AcDb2dPolyline,AcDb3dPolyline")
     (group-by-num verts 3)
     )
    ((eq (vlax-get pline_obj 'Objectname)
         "AcDbPolyline")
     (group-by-num verts 2)
     )
    (T nil)
    )
  )
  )
(vl-load-com)
;;main part
(defun C:SSP  (/ *error* acsp adoc con osmd plent sscon sspline vertices_list)

  (defun *error* (msg)
    (cond
      ((not msg))
      ((wcmatch (strcase msg) "*QUIT*,*CANCEL*"))
      (T (princ (strcat "\nError: " msg)))
    )
  (if osmd   (setvar "osmode" osmd))
  (vl-cmdf "ucs" "w")
  (vl-cmdf "-view" "swiso")
  (vla-regen adoc acactiveviewport)
  (vla-endundomark adoc)
    (princ)
  )

  (setq  adoc (vla-get-activedocument
         (vlax-get-acad-object)
         )
  acsp (vla-get-block
         (vla-get-activelayout adoc)
         )
  )
  (vla-startundomark adoc)
  (vl-cmdf "ucs" "w")

  (setq osmd (getvar "osmode"))
  (setvar "osmode" 0)
  (alert "\nSelect the solid first\nthan select the polyline")
  (if (and
  (setq sscon (ssget "+.:S:N" (list (cons 0 "3DSOLID"))))
  (setq sspline (ssget "+.:S:N" (list (cons 0 "*POLYLINE")))))
    (progn
      (setq vertices_list
       (get-vexs
         (vlax-ename->vla-object
     (setq plent (ssname sspline 0)))))
      (vl-cmdf "._slice" (ssname sscon 0) "" "_O" plent
         (trans '(0. 0. -100000.) 0 1);;<-- change on '(0. 0. 100000.) if you need to keep the upper section

      )))

  (*error* nil)
  (princ)
  )
(prompt "\n=======================================================\n")
(prompt "\n\t\t***\tStart command with SSP\t***")
(prompt "\n=======================================================\n")
(princ)

~'J'~

DEVITG

  • Bull Frog
  • Posts: 479
Re: can you fix this lsp ( slice solid with polyline)
« Reply #8 on: January 27, 2009, 04:20:13 AM »
Maybe I'm wrong .
But I think Dussla want to slice the solid by the Z axis .

Like the wedge is a piece of hardboard , and the polyline the jig saw phat.

As I say,  maybe I wrong.

Here is how I think the slice had to be do.



« Last Edit: January 27, 2009, 04:35:12 AM by DEVITG »
Location @ Córdoba Argentina Using ACAD 2019  at Window 10