Author Topic: 3DPLINE TO 3DFACE  (Read 1632 times)

0 Members and 1 Guest are viewing this topic.

catoscuro

  • Mosquito
  • Posts: 4
3DPLINE TO 3DFACE
« on: September 20, 2015, 05:06:01 PM »
If you could help me, do I require;
1. a rectangular polyline selecting 2 opposite points
2. exploit the polyline to be lines
3.- ask variables SR1 and SR2 to bring them a value, and if possible to take the last entered value.
4. apply the command EDGESURF selecting the first line of the left, then the right line, then the top line and the bottom line finally, end the command
5. delete the lines that were to explode the polyline.

I hope I was clear, I give you an example. Regards.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: 3DPLINE TO 3DFACE
« Reply #1 on: September 22, 2015, 04:48:12 AM »
Here is a solution. There is no need for the intermediate steps you describe.
Code - Auto/Visual Lisp: [Select]
  1. (defun c:3DFaceArray ( / doc pt1 pt2)
  2.   (if (= (logand (getvar 'undoctl) 8) 8)
  3.     (vla-endundomark doc)
  4.   )
  5.   (if
  6.     (and
  7.       (setq pt1 (getpoint "\nPoint 1: "))
  8.       (setq pt2 (getpoint pt1 "\nPoint 2: "))
  9.       (setq pt2 (list (car pt2) (cadr pt2) (caddr pt1)))
  10.       (or
  11.         (not (equal pt1 pt2 1e-8))
  12.         (prompt "\nError: points equal in XY plane ")
  13.       )
  14.       (progn
  15.         (initget (+ 6 (if *3DFA_nrX* 0 1)))
  16.         (setq *3DFA_nrX*
  17.           (cond
  18.             (
  19.               (getint
  20.                 (strcat
  21.                   "\nNumber of faces in the X direction: "
  22.                   (if *3DFA_nrX* (strcat "<" (itoa *3DFA_nrX*) ">: ") "")
  23.                 )
  24.               )
  25.             )
  26.             (
  27.               *3DFA_nrX*
  28.             )
  29.           )
  30.         )
  31.       )
  32.       (progn
  33.         (initget (+ 6 (if *3DFA_nrY* 0 1)))
  34.         (setq *3DFA_nrY*
  35.           (cond
  36.             (
  37.               (getint
  38.                 (strcat
  39.                   "\nNumber of faces in the Y direction: "
  40.                   (if *3DFA_nrY* (strcat "<" (itoa *3DFA_nrY*) ">: ") "")
  41.                 )
  42.               )
  43.             )
  44.             (
  45.               *3DFA_nrY*
  46.             )
  47.           )
  48.         )
  49.       )
  50.     )
  51.     (3DFaceArray_Create
  52.       (if (= 1 (getvar 'cvport))
  53.         (vla-get-paperspace doc)
  54.         (vla-get-modelspace doc)
  55.       )
  56.       pt1
  57.       pt2
  58.       *3DFA_nrX*
  59.       *3DFA_nrY*
  60.     )
  61.   )
  62.   (princ)
  63. )
  64.  
  65. ; Note: pt1 and pt2 in UCS.
  66. (defun 3DFaceArray_Create (blk pt1 pt2 nrX nrY / deltaX deltaY z orgNrY)
  67.   (setq deltaX (/ (- (car pt2) (car pt1)) nrX))
  68.   (setq deltaY (/ (- (cadr pt2) (cadr pt1)) nrY))
  69.   (setq z (caddr pt1))
  70.   (setq orgNrY nrY)
  71.   (repeat nrX
  72.     (setq nrX (1- nrX))
  73.     (repeat (setq nrY orgNrY)
  74.       (setq nrY (1- nrY))
  75.       (vlax-invoke
  76.         blk
  77.         'add3dface
  78.         (trans (list (- (car pt2) (* (1+ nrX) deltaX)) (- (cadr pt2) (* (1+ nrY) deltaY)) z) 1 0) ; BL
  79.         (trans (list (- (car pt2) (* nrX deltaX))      (- (cadr pt2) (* (1+ nrY) deltaY)) z) 1 0) ; BR
  80.         (trans (list (- (car pt2) (* nrX deltaX))      (- (cadr pt2) (* nrY deltaY)) z)      1 0) ; TR
  81.         (trans (list (- (car pt2) (* (1+ nrX) deltaX)) (- (cadr pt2) (* nrY deltaY)) z)      1 0) ; TL
  82.       )
  83.     )
  84.   )
  85. )
  86.  
  87. (princ "\nUse 3DFaceArray ")

catoscuro

  • Mosquito
  • Posts: 4
Re: 3DPLINE TO 3DFACE
« Reply #2 on: September 22, 2015, 01:52:24 PM »
Roy, you did a great job, this routine is excellent, I will save a lot of work, thanks.