• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

copy with rotation (and translation)

  • Thread starter Thread starter Gio_S
  • Start date Start date

Gio_S

Guest
I swear it's not laziness, but maybe for someone who has geometry in his head it's been a quarter of an hour... for me would be two working days (at least)
problem (grade response also only for routine on the simple point) :
take a 3d surface, consisting of 3dfaces
articulated on a floor, I make example, a portion of porphyry in cubes with its engraved stems .... .
and... .
rotate/translate each face around a cylinder, creating as a 3d stamp that will work on rotation (type roller from upholsterer).
since the result must be modular and repetitive, the length of the surface is equal to the diameter of the cylinder * lazy.
I understand that I ask a lot:)
the purpose is to create "types" from modeling to create 3d surfaces on malleable materials placed on the floor.
 
I forgot... in pure lisp, are not equipped for vba and similar
I began to develop on the point in the most elementary and classic way, I find the length of the arc formed by the rotation of the point (which is its x flatness on the plane on which the drawing lies), whose angle brings me to the breast and cosine, which will be respectively the z and x of the new created point (y does not change, since the axis of the cylinder has the vector 0.1,0). . .
I hope I started right...
 
an hour yesterday and half an hour today.. all wrong but equals the classic "hello world" on the screen ahahah
therefore, to begin I used simple lines, in a picture on the positive dial (orig. 0,0,0) side = pi
I gave the command and, I suppose, nonle rotated on the cylinder, but on its 90-degree spike
(see sequence development.. 1 red was the original, 1 black the line created)
Meanwhile rest and let him decantate, then I take it back in hand, but with 3dface scattered, which becomes more legible.
Clear that it is all wrong, does not consider the negative dial values... and I don't have the pallidest idea (for now) of why he focused everything on a 90-degree... but the (false proportions) and celebrations, there are.Immagine.webp
Code:
(defun hprint()
(setq selez nil)
(setq selez(ssget))
(if (/= selez nil)
(progn)
(setq l(sslength selez)
(setq l(1- l))
(Sectq na 0)
(while(< = na l)
(setq ename(sname selez na))
(setq alist(entget ename))
(if(= "line"(cdr(assoc 0 alist))))
(progn)
(setq a(cdr(assoc 10 alist))))
(setq b(cdr(assoc 11 alist))))
(setq ax (car a) ay (cadr a) az (caddr a))
(setq bx (car b) by (cadr b) bz (caddr b)))
; assumed to more develop the tape to be wrapped, so that the cylinder is 1
;1415926535
(setq angrada (/ ax pi)
(setq angradb (/ bx pi))

(setq newaz)
(setq newax (cos angrada)
(setq neway ay) ; readability only

(setq newbz (sin angradb))
(setq newbx (cos angradb))
(setq newby by) ; only for readability

(setq newa (list newax neway newaz) )
(setq newb (list newbx newby newbz) )
(command "line" newa newb ")
)
)
(Sectq na(1+ na))
)
)
)
)
 
I'm getting closer, code rewrites a little to my nose without knowing what I'm doing.
However it works, but with an obligation that I would like to remove.
the "ship", i.e. the length of the plant, built to 3dface, which must rotate forming exactly a roller, with this code, must be long exactly (pi * more * 2) i.e. almost 20.
I would like it to be free, even if for my purpose it's all right.
i.e. I am pleased that any plant enveloped forming its corresponding closed ring.
Clipboard01.webp
Code:
(defun hprint()
(setq selez nil)
(setq selez(ssget))
(if (/= selez nil)
(progn)
(setq l(sslength selez)
(setq l(1- l))
(Sectq na 0)
(while(< = na l)
(setq ename(sname selez na))
(setq alist(entget ename))
(if(= "3dface"(cdr(assoc 0 alist))))
(progn)
(setq a (cdr(assoc 10 alist)) b (cdr(assoc 11 alist) c (cdr(assoc 12 alist)) d (cdr(assoc 13 alist))))

(setq ax (car a) ay (cadr a) az (caddr a) )
(setq bx (car b) by (cadr b) bz (caddr b) )
(setq cx (car c) cy (cadr c) cz (caddr c) )
(setq dx (car dy) (cadr d) dz (caddr d) )

;3.1415926535
(setq angrada (/ ax pi)
(setq angradb (/ bx pi))
(setq angradc (/ cx pi)
(setq angradd (/ dx pi)


(setq newaz (*) (sin angrada) pi)
(setq newax (* (cos angrada) pi)
(setq neway ay) ; readability only

(setq newbz) (sin angradb) pi)
(setq newbx (* (cos angradb) pi)
(setq newby by) ; only for readability

(sin angradc) pi)
(setq newcx (* (cos angradc) pi)
(setq newcy cy) ; only for readability

(sin angradd)
(setq newdx (* (cos angradd) pi)
(setq newdy dy) ; only for readability

(setq newa (list newax neway newaz) )
(setq newb (list newbx newby newbz) )
(setq newc (list newcx newcy newcz) )
(setq newd (list newdx newdy newdz) )

(command "3dface" newa newb newc ")
)
)
(Sectq na(1+ na))
)
)
; 19.7392
)
)
 
rehearsal again (write me if I shake), but this job is taking me.
I can't leave the old code because I simplified it, but especially because I had to make an important fix. it worked by bending ring (as you see here in the post above), but it was unable to understand the relief of the project. practically created me a roller, and ok, but taking the faces from the original plan design as if everything was at zero altitude.
I realized by inserting the leaks on the negative of the porphyry that I am using as a test, and I introduced a corrective that reads the basic model in its three dimensions.
better than the explanation I think it is worth the image.
But now I have to adjust the length of the base model again if you want to get a perfect cilindo with the complete rotation.
As I wrote, it's not parametric for now, so I have to find the exact length in reverse engineering.
However the new code is now exact, i.e., I read a model not only two-dimensional.
Clipboard01.webp
Clipboard02.webp
Code:
(defun hprint()
(setq selez nil)
(setq selez(ssget))
(if (/= selez nil)
(progn)
(setq l(sslength selez)
(setq l(1- l))
(Sectq na 0)
(while(< = na l)
(setq ename(sname selez na))
(setq alist(entget ename))
(if(= "3dface"(cdr(assoc 0 alist))))
(progn)
(setq a (cdr(assoc 10 alist)) b (cdr(assoc 11 alist) c (cdr(assoc 12 alist)) d (cdr(assoc 13 alist))))

(setq ax (car a) ay (cadr a) az (caddr a) )
(setq bx (car b) by (cadr b) bz (caddr b) )
(setq cx (car c) cy (cadr c) cz (caddr c) )
(setq dx (car dy) (cadr d) dz (caddr d) )

;3.1415926535
(setq angrada ax)
(setq angradb bx)
(setq angradc cx)
(setq angradd dx)

(Sectq quota (- 1 az))
(setq newaz (*(sin angrada)quota))
(setq newax (*(cos angrada)quota))
(setq neway ay) ; readability only

(Sectq quota (- 1 bz))
(setq newbz (*(sin angradb)quota))
(setq newbx (*(cos angradb)quota))
(setq newby by) ; only for readability

(Sectq quota (- 1 cz))
(setq newcz (*(sin angradc)quota))
(setq newcx)
(setq newcy cy) ; only for readability

(Sectq quota (- 1 dz))
(sin angradd)quota)
(setq newdx)
(setq newdy dy) ; only for readability

(setq newa (list newax neway newaz) )
(setq newb (list newbx newby newbz) )
(setq newc (list newcx newcy newcz) )
(setq newd (list newdx newdy newdz) )

(command "3dface" newa newb newc ")
)
)
(Sectq na(1+ na))
)
)
; 19.7392
)
)
 
Clipboard01.webpCome back. end of the story, you do not need to update the last list because it passed every test.
in case someone wanted to try it or use it I provide the definitive indications.
1) the ribbon to wrap, to form the exact drum, must be 2pi long on the x axis. a pleasure y e z. the whole place in the positive dial (I place the tape from 0.0.0).
2) I do not make the parameter code because it is useless, the resulting cylinder will be scalable already of its own.
3) the engravings on the drum are to be detected with positive z on the tape (it wraps upwards).
4) before launching the command it is appropriate to create a new layer for the cylinder and to make it current, to release between them tape and roller, and to be able to manipulate them without difficulty, having both origin 0.0.0 will be partially overlapped.
5) the code only supports 3dface entities. others will be ignored.
 
I return to the subject because I came the vent, let's say the need, after creating a roller, and maybe having modified it, to bring everything back on a 3d floor.
much more complicated, bring back on a sheet the topography of the cylinder.
I quarreled quite a bit with the bower, which in lisp is not there, packaging the formulas, then I gave up, opting for a more rustic method that makes the cad work, in short making him draw the arc of each point on the cylinder, making me say the length "distinct", and reporting said measure as x-value of that point compared to the common origin.
not simple stuff, especially because a face can stand on the cylinder on horseback in less than 360 degrees and more than 0 degrees, which makes me the arc not of trivial development. from here, the controls; the "pure" that tells me if a face is in the range 0-360 or not, if then one or more vertices over the 360 .
However, the diameter of the cylinder must be mandatory 2 (rough 1), and its origin, the center of the base, placed at 0.0.0. must be laid as a rolled carpet, i.e. 0.0.0, the cylinder height will be placed according to a y positive.
this is precisely because the result will be like unrolling a cylinder carpet on the floor, placed along the y axis, spreading it on the x axis. like when you created it.
even here, better place on a new layer before launching the routine, because the new created form does not intertwin with the first and is easily selectable.
It's a "timbre", so it's only verified for "incisions" on the cylinder diameter, which will become positive volumes placed on the carpet. I didn't check what happens if "the cylinder comes out protuberances, because it wasn't my problem. is a "continuous stamp" 3d. What is engraved on the cylinder, will result in an adjective on the unrolled carpet with its topography.
of course thank you if by chance someone had ideas with a sharper algorithm!
Code:
(defun mprint()
  (setq selez nil)
  (setq selez(ssget))
  (if (/= selez nil)
     (progn
          (setq l(sslength selez))
          (setq l(1- l))
          (setq na 0)
          (while(<= na l)
               (setq ename(ssname selez na))
               (setq alist(entget ename))
               (if(= "3dface"(cdr(assoc 0 alist)))
                   (progn
                       (setq a (cdr(assoc 10 alist)) b (cdr(assoc 11 alist)) c (cdr(assoc 12 alist)) d (cdr(assoc 13 alist)))
                       (setq ax (car a) ay (cadr a) az (caddr a) )
                       (setq bx (car b) by (cadr b) bz (caddr b) )
                       (setq cx (car c) cy (cadr c) cz (caddr c) )
                       (setq dx (car d) dy (cadr d) dz (caddr d) )
                       (if (or (< az 0)(< bz 0)(< cz 0)(< dz 0))   
                              (setq sud 1)
                              (setq sud 0)
                       )
                       (setq cross 0)
                       (if (< az -0.0001)(setq cross (+ 1 cross)))
                       (if (< bz -0.0001)(setq cross (+ 1 cross)))
                       (if (< cz -0.0001)(setq cross (+ 1 cross)))
                       (if (< dz -0.0001)(setq cross (+ 1 cross)))
                       (if (or (= cross 4)(= cross 0)) (setq pure 1)(setq pure 0))

;................
                      (setq newaz (- 1 (sqrt  (+  (* ax ax)  (* az az))) ))
                      (setq pointcent   (list 100 0 0) )
                      (setq pointstart   (list 101 0 0) )
                      (setq pointend   (list (+ 100 ax) az 0) )
                      (if (and (equal ax 1 0.0001) (= sud 1))
                           (setq newax 6.28318531)
                           (progn
                                   (command "arc" "c" pointcent pointstart pointend)
                                   (setq selez2 (ssget pointstart))
                                   (setq ename2 (ssname selez2 0))
                                   (setq nalist (entget ename2))
                                   (setq basarc (cdr(assoc 50 nalist)))
                                   (setq endarc (cdr(assoc 51 nalist)))
                                   (setq svilarc (- endarc basarc))
                                   (entdel ename2)
                                   (setq newax  svilarc)
                           )
                      )
                      (setq neway ay) ;solo per leggibilità
;............

                      (setq newbz (- 1 (sqrt  (+  (* bx bx)  (* bz bz))) ))
                      (setq pointcent   (list 100 0 0) )
                      (setq pointstart   (list 101 0 0) )
                      (setq pointend   (list (+ 100 bx) bz 0) )
                      (if (and (equal bx 1 0.0001) (= sud 1))
                           (setq newbx 6.28318531)
                             (progn
                                    (command "arc" "c" pointcent pointstart pointend)
                                    (setq selez2 (ssget pointstart))
                                    (setq ename2 (ssname selez2 0))
                                    (setq nalist(entget ename2))
                                    (setq basarc (cdr(assoc 50 nalist)))
                                    (setq endarc (cdr(assoc 51 nalist)))
                                    (setq svilarc (- endarc basarc))
                                    (setq newbx svilarc)
                                    (entdel ename2)
                            )
                       )
                       (setq newby by) ;solo per leggibilità
;............

                      (setq  newcz (- 1 (sqrt  (+  (* cx cx)  (* cz cz))) ))
                      (setq pointcent   (list 100 0 0) )
                      (setq pointstart   (list 101 0 0) )
                      (setq pointend   (list (+ 100 cx) cz 0) )
                      (if (and (equal cx 1 0.0001) (= sud 1))
                                 (setq newcx 6.28318531)
                                 (progn
                                      (command "arc" "c" pointcent pointstart pointend)
                                      (setq selez2 (ssget pointstart))
                                      (setq ename2 (ssname selez2 0))
                                      (setq nalist (entget ename2))
                                      (setq basarc (cdr(assoc 50 nalist)))
                                      (setq endarc (cdr(assoc 51 nalist)))
                                      (setq svilarc (- endarc basarc))
                                      (setq newcx svilarc)
                                      (entdel ename2)
                                 )
                      )
                      (setq newcy cy) ;solo per leggibilità
;............

                      (setq  newdz (- 1 (sqrt  (+  (* dx dx)  (* dz dz))) ))
                      (setq pointcent   (list 100 0 0) )
                      (setq pointstart   (list 101 0 0) )
                      (setq pointend   (list (+ 100 dx) dz 0) )
                      (if (and (equal dx 1 0.0001) (= sud 1))
                                   (setq newdx 6.28318531)
                                   (progn
                                          (command "arc" "c" pointcent pointstart pointend)
                                          (setq selez2 (ssget pointstart))
                                          (setq ename2 (ssname selez2 0))
                                          (setq nalist(entget ename2))
                                          (setq basarc (cdr(assoc 50 nalist)))
                                          (setq endarc (cdr(assoc 51 nalist)))
                                          (setq svilarc (- endarc basarc))
                                          (setq newdx svilarc)
                                          (entdel ename2)
                                    )
                         )
                         (setq newdy dy) ;solo per leggibilità
                         (setq newa   (list newax neway newaz) )
                         (setq newb   (list newbx newby newbz) )
                         (setq newc   (list newcx newcy newcz) )
                         (setq newd   (list newdx newdy newdz) )

                         (if (= 1 pure)

                                   (command "3dface" newa newb newc newd "")
                                   (progn
                                           (if (< ax 0)
                                                   (command "3dface" newa newb newc newd "")
                                                   (progn
                                                           (if (< newax  pi) (setq newax (+ pi pi  newax))) 
                                                           (if (< newbx  pi) (setq newbx (+ pi pi  newbx))) 
                                                           (if (< newcx  pi) (setq newcx (+ pi pi  newcx))) 
                                                           (if (< newdx  pi) (setq newdx (+ pi pi  newdx))) 

                                                            (setq newa   (list newax neway newaz) )
                                                            (setq newb   (list newbx newby newbz) )
                                                            (setq newc   (list newcx newcy newcz) )
                                                            (setq newd   (list newdx newdy newdz) )
                                                            (command "3dface" newa newb newc newd "")
                                                      )
                                                )
                                     )
                           ) ;  close if pure
                    ) ;  close progn if 3dface
                ) ;endif 3dface
               (setq na(1+ na))
         ) ;  close while na
       ) ;  close progn selez
    ) ;  close if selez
) ;close defun
 
the "reverse" that I posted a long time ago, to create continuous stamps in cylinder, it returned useful to me while having "stressed", and without problems.
I had created a snowy pint with overlapping waffles, but it was too regular, and besides, too difficult to select the branches one by one to stretch them down without messing up everything.
I thought of trying my reverse engineering code of stamp without too much confidence. ergo:
maximum radius to 2.00.
center of pine cone base placed at 0.0.0
stretched from 0.0.0 with growth y (remember, as a rolled carpet stretched on the ground)
applied the defun mprint (activating another layer, otherwise the new shape is intertwined with the original and it is uncomfortable to treat it), I found everything unrolled on the floor, like a lawn from which the branches start vertically (but with negative z, I remember, it is for stamps).
easy then stretch them one by one.
and when I'm done, I've "returned" with hprint.
and here's the result.
Remember, the radius goes to 2 because the algorithm uses the pi without parameterization.
the finished work then you can reproportionate as you want.
Good Christmas for a long time!
 

Attachments

  • Clipboard01.webp
    Clipboard01.webp
    30.5 KB · Views: 4

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

No members online now.
ciao
Back
Top