Author Topic: Delete 3D faces that are NOT vertical  (Read 9423 times)

0 Members and 1 Guest are viewing this topic.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Delete 3D faces that are NOT vertical
« Reply #15 on: September 04, 2015, 04:25:29 PM »
You are right Lee. I made the wrong assumption that a 'face segment' would be created between the first 3 coordinates of the face. But apparently it is created between the 1st, 2nd and 4th coordinate.

Code - Auto/Visual Lisp: [Select]
  1. ; (3DfaceVertical_P (vlax-ename->vla-object (car (entsel))))
  2. (defun 3DfaceVertical_P (obj / fuzz ptLst)
  3.   (setq fuzz 1e-8)
  4.   (setq ptLst
  5.     (mapcar
  6.       '(lambda (idx)
  7.         (vlax-safearray->list
  8.           (vlax-variant-value
  9.             (vla-get-coordinate obj idx)
  10.           )
  11.         )
  12.       )
  13.       '(0 1 2 3)
  14.     )
  15.   )
  16.   (and
  17.     ; (not (equal (car ptLst) (caddr ptLst) fuzz)) ; EDIT: code commented out: 'folded' surface.
  18.     (not (equal (cadr ptLst) (cadddr ptLst) fuzz)) ; No surface.
  19.     (not (PointListColinear_P ptLst))              ; No surface.
  20.     (setq ptLst (mapcar '_List_LastRemove ptLst))  ; Project the points.
  21.     (or
  22.       (equal (cadr ptLst) (cadddr ptLst) fuzz)     ; Vertical crease. EDIT: also catches other situations.
  23.       (PointListColinear_P ptLst)
  24.     )
  25.   )
  26. )
EDIT: See comments.
« Last Edit: September 05, 2015, 02:56:59 AM by roy_043 »

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Delete 3D faces that are NOT vertical
« Reply #16 on: September 04, 2015, 04:36:11 PM »
No worries Roy; nice code.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Delete 3D faces that are NOT vertical
« Reply #17 on: September 05, 2015, 02:58:17 AM »
I have edited the code in my previous post. :roll:

David Bethel

  • Swamp Rat
  • Posts: 656
Re: Delete 3D faces that are NOT vertical
« Reply #18 on: September 05, 2015, 05:32:50 AM »
There are probably dozens of scenarios for 3dface point alignments and orders.  That is 1 of the great things about them.

  • Single point - (4) coincidental pts
  • Line shape - 2 unique pts -

(10 11) -> (12 13) 
(10 12) -> (11 13)
(10 13) -> (11 12)
(10) -> (11 12 13)
(11) -> (10 12 13)
(12) -> (10 11 13)
(13) -> (10 11 12)
  • triangle shape... (3) unique points

And then add in all colinear coplaner possibilties...

Just to get started.

-David
R12 Dos - A2K

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Delete 3D faces that are NOT vertical
« Reply #19 on: September 07, 2015, 06:01:37 AM »
Another way of using the intersection:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:test (/ E P Z)
  2.   (if (setq e (ssget "_:L" '((0 . "3DFACE"))))
  3.     (foreach e (vl-remove-if (function listp) (mapcar (function cadr) (ssnamex e)))
  4.       ;;(setq e(ssname e 0))
  5.       (setq p (vl-remove nil
  6.                          (mapcar (function (lambda (a)
  7.                                              (if (< 9 (car a) 15)
  8.                                                (cdr a)
  9.                                              )
  10.                                            )
  11.                                  )
  12.                                  (entget e)
  13.                          )
  14.               )
  15.             p (if (member (car p) (cdr p))
  16.                 (list (caddr p) (cadddr p) (car p) (cadr p))
  17.                 p
  18.               )
  19.             z (mapcar (function +) (car p) '(0 0 1))
  20.             z (cond ((inters (car p) z (cadr p) (caddr p) nil))
  21.                     ((inters (car p) z (caddr p) (cadddr p) nil))
  22.               )
  23.       )
  24.       (if (or (not z) (not (member z p)))
  25.         (entdel e)
  26.       )
  27.     )
  28.   )
  29. )

without optimization, just an example...

Dilan

  • Newt
  • Posts: 23
Re: Delete 3D faces that are NOT vertical
« Reply #20 on: November 02, 2018, 04:23:25 AM »
Hello. Sorry that the question is off topic
How to change the height of all the vertices of a set of 3d faces on the value entered by the user?

ribarm

  • Gator
  • Posts: 3255
  • Marko Ribar, architect
Re: Delete 3D faces that are NOT vertical
« Reply #21 on: November 02, 2018, 11:13:16 AM »
Hello. Sorry that the question is off topic
How to change the height of all the vertices of a set of 3d faces on the value entered by the user?

I don't quite understand, use MOVE command perhaps?
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

David Bethel

  • Swamp Rat
  • Posts: 656
Re: Delete 3D faces that are NOT vertical
« Reply #22 on: November 03, 2018, 06:04:16 AM »
If you are trying change the Z axis only :

Code: [Select]
(defun c:3df-zaxs (/ z ss i en ed)

  (initget 1)
  (setq z (getdist "\nNew Z Value:   "))

  (while (setq ss (ssget (list (cons 0 "3DFACE"))))
         (setq i 0)
         (while (setq en (ssname ss i))
                (setq ed (entget en))
                (foreach p '(10 11 12 13)
                      (setq ed (subst (list p (cadr (assoc p ed))
                                              (caddr (assoc p ed))
                                               z)
                                      (assoc p ed) ed)))
                (entmod ed)
                (setq i (1+ i))))
  (prin1))

Note that all 3dface values are WCS

-David
R12 Dos - A2K

Dilan

  • Newt
  • Posts: 23
Re: Delete 3D faces that are NOT vertical
« Reply #23 on: November 03, 2018, 09:47:37 PM »
If you are trying change the Z axis only :

Code: [Select]
(defun c:3df-zaxs (/ z ss i en ed)

  (initget 1)
  (setq z (getdist "\nNew Z Value:   "))

  (while (setq ss (ssget (list (cons 0 "3DFACE"))))
         (setq i 0)
         (while (setq en (ssname ss i))
                (setq ed (entget en))
                (foreach p '(10 11 12 13)
                      (setq ed (subst (list p (cadr (assoc p ed))
                                              (caddr (assoc p ed))
                                               z)
                                      (assoc p ed) ed)))
                (entmod ed)
                (setq i (1+ i))))
  (prin1))

Note that all 3dface values are WCS

-David
Hello David.
This is not exactly what I need. Your program replaces the height of the vertices of 3D faces. I need to change the height of the vertices of 3d faces.
For example, add to all vertices +5.000, or -15.000

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Delete 3D faces that are NOT vertical
« Reply #24 on: November 04, 2018, 04:55:55 AM »
If you are trying change the Z axis only :

Code: [Select]
(defun c:3df-zaxs (/ z ss i en ed)

  (initget 1)
  (setq z (getdist "\nNew Z Value:   "))

  (while (setq ss (ssget (list (cons 0 "3DFACE"))))
         (setq i 0)
         (while (setq en (ssname ss i))
                (setq ed (entget en))
                (foreach p '(10 11 12 13)
                      (setq ed (subst (list p (cadr (assoc p ed))
                                              (caddr (assoc p ed))
                                               z)
                                      (assoc p ed) ed)))
                (entmod ed)
                (setq i (1+ i))))
  (prin1))

Note that all 3dface values are WCS

-David
Hello David.
This is not exactly what I need. Your program replaces the height of the vertices of 3D faces. I need to change the height of the vertices of 3d faces.
For example, add to all vertices +5.000, or -15.000

In David's code, change:

Code: [Select]
                                               z)
to:

Code: [Select]
                                               (+ (cadddr (assoc p ed)) z))
And perhaps change the prompt to:

Code: [Select]
  (setq z (getdist "\nZ value adjustment:   "))

ribarm

  • Gator
  • Posts: 3255
  • Marko Ribar, architect
Re: Delete 3D faces that are NOT vertical
« Reply #25 on: November 04, 2018, 06:49:16 AM »
David's code is something different than I thought - it's like flatten+move along Z automatically... But Lee's comment is just like I said - it's pure move along Z - no need for coding...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

David Bethel

  • Swamp Rat
  • Posts: 656
Re: Delete 3D faces that are NOT vertical
« Reply #26 on: November 04, 2018, 07:27:42 AM »
How to change the height of all the vertices of a set of 3d faces on the value entered by the user?

I interpreted the OP as needing then face edited to the value specified, not by the value specified.  Oh well.  -David
R12 Dos - A2K

ribarm

  • Gator
  • Posts: 3255
  • Marko Ribar, architect
Re: Delete 3D faces that are NOT vertical
« Reply #27 on: November 04, 2018, 11:17:41 AM »
How to change the height of all the vertices of a set of 3d faces on the value entered by the user?

I interpreted the OP as needing then face edited to the value specified, not by the value specified.  Oh well.  -David

David, nothing wrong with your judgement, I also don't copy what OP wanted exactly and why this topic was revived, but then I guess better anything than nothing, so I give my kudo to you if that's possible...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

David Bethel

  • Swamp Rat
  • Posts: 656
Re: Delete 3D faces that are NOT vertical
« Reply #28 on: November 04, 2018, 12:35:00 PM »
No Problem.   8-)  Sometimes my interpretations are way off.  Besides, I use these type of 3face routines on a regular basis ( I ripped this 1 from an existing X Y or Z axis function )  -David
R12 Dos - A2K

Dilan

  • Newt
  • Posts: 23
Re: Delete 3D faces that are NOT vertical
« Reply #29 on: November 04, 2018, 04:57:36 PM »
If you are trying change the Z axis only :

Code: [Select]
(defun c:3df-zaxs (/ z ss i en ed)

  (initget 1)
  (setq z (getdist "\nNew Z Value:   "))

  (while (setq ss (ssget (list (cons 0 "3DFACE"))))
         (setq i 0)
         (while (setq en (ssname ss i))
                (setq ed (entget en))
                (foreach p '(10 11 12 13)
                      (setq ed (subst (list p (cadr (assoc p ed))
                                              (caddr (assoc p ed))
                                               z)
                                      (assoc p ed) ed)))
                (entmod ed)
                (setq i (1+ i))))
  (prin1))

Note that all 3dface values are WCS

-David
Hello David.
This is not exactly what I need. Your program replaces the height of the vertices of 3D faces. I need to change the height of the vertices of 3d faces.
For example, add to all vertices +5.000, or -15.000

In David's code, change:

Code: [Select]
                                               z)
to:

Code: [Select]
                                               (+ (cadddr (assoc p ed)) z))
And perhaps change the prompt to:

Code: [Select]
  (setq z (getdist "\nZ value adjustment:   "))
thank you Lee