Author Topic: How would you array this horizotally  (Read 7554 times)

0 Members and 1 Guest are viewing this topic.

daron

  • Guest
Re: How would you array this horizotally
« Reply #15 on: May 09, 2008, 04:19:47 PM »
Code: [Select]
(arxunload "geom3d.arx")Okay, I see it now. You're taking bits and pieces and trying to put them together. That bit is from fatty, but in the code you posted since, the reason for it is missing. Step through the code piece by piece in the vlide. You'll quickly find the mistakes. Also, to make life easy on you you can group things like:
Code: [Select]
 (setq width 3.625
        height 7.250
        cheight 7.625
  )
It also works with command, but I like the way fatty used apply in this case. It doesn't work on setvar, which is why I came up with my functions listed above.


Just some pointers to help you along. I see that you have a long road ahead of you with a couple of items you've decided to take on. If you learn good practices now, it'll save you later.

Hi, mate
First of all change jjpt1 on jpt1 and height on jheight
Then you need to draw the polyline to be extruded
correctly, because of in you code this was drawn as
a self-intersected and you should't to extrude this
contour
Attach the sample picture of this polyline you want
to create
[And also I'm still avoid to use polar function for
parametric drafting (IMO only)]



~'J'~

I think you forgot to attach the picture.

Thank you,

Brad

I think he's asking you to attach something, but I could be wrong.

Fatty

  • Guest
Re: How would you array this horizotally
« Reply #16 on: May 09, 2008, 04:53:39 PM »
Ah, you know, I'm absolutely dumb in English grammar
Yes, I want to see the shape you need to extrude,
let you attach the picture here
Sorry again for my poor english :oops:

~'J'~

One Shot

  • Guest
Re: How would you array this horizotally
« Reply #17 on: May 09, 2008, 07:54:30 PM »
Ah, you know, I'm absolutely dumb in English grammar
Yes, I want to see the shape you need to extrude,
let you attach the picture here
Sorry again for my poor english :oops:

~'J'~


Fatty,

please the attachment for the step that this lisp would take plus final application.  Please look in Model space and in the paper Space Tab.

Fatty

  • Guest
Re: How would you array this horizotally
« Reply #18 on: May 10, 2008, 12:21:39 AM »
Much better
I'll try :)

~'J'~

Fatty

  • Guest
Re: How would you array this horizotally
« Reply #19 on: May 10, 2008, 05:12:00 AM »
Give this a shot

Code: [Select]
(defun C:try  (/      brick  cheight    cnt   diff dist height joint  jp1    jp10   jp11   jp12   jp2 jp3
       jp4    jp5    jp6    jp7    jp8   jp9 leng lp     mark   mjoin  mp1    mp2    num   overhang
       p1     p2     ptlist response   rp sjoint step   width  x      y)

  (command "._undo" "_BE")
  (setvar "osmode" 0)
  (setvar "cmdecho" 0)
  (setq width 2.25
height 7.625
cheight 3.625
overhang 3.25
joint 0.375)
  (setvar "orthomode" 1)
  (setq lp (getpoint "\nPick point top left corrner of opening: ")
rp (getpoint lp "\nPick point top right corrner of opening: ")
)
  (initget "Yes No")
  (setq response (getkword
   "\nIs there an overhang beyond the opening or no opening?\n (Yes/No) <Y>: "))
  (if (not response)
    (setq response "Yes"))
  (if (eq "Yes" response)
    (progn
      (setq mark T)
      (setq lp (list (- (car lp) overhang) (cadr lp))
    rp (list (+ (car rp) overhang) (cadr rp))
    )
      )
    (setq mark nil)
    )

  (setq dist (distance (trans lp 0 1) (trans rp 0 1)))
  (setq cnt (fix (/ dist width)))
  (setq leng (* cnt width))
  (setq diff (- dist leng))

  (if (< diff 0)
    (progn
      (setq cnt (1- cnt))
      (setq leng (* cnt width))
      (setq diff (- dist leng))))
  (setq mjoin (/ diff (1- cnt)))
  (alert (vl-princ-to-string cnt))
  ;; recalculate till the joint will have a desired size :
  (while (< mjoin 0.25)
    (progn
      (setq cnt (1- cnt))
      (setq leng (* cnt width))
      (setq diff (- dist leng)))
    (setq mjoin (/ diff (1- cnt))))
  (setq leng (+ (* cnt width) (* (1- cnt) mjoin)))

  ;; compare result with length of opening 
  (if (not (equal leng dist 0.001))
    (progn
      (princ "\nWrong result, you're the dumb, Fatty")
      (exit)
      (princ)
      )
    )
  ;; get the step of an array 
  (setq step (+ width mjoin))

  ;; draw a single brick
  (setq p1 (list (car lp) (cadr lp))
p2 (list (+ (car lp) width) (+ (cadr lp) height))
)

  (command "._zoom" "_W" p1 p2)
  (setvar "clayer" "0")
  (setvar "cecolor" "22")
  (command "._rectang" p1 p2)
  (command "extrude" "L" "" cheight)
  ;; array 
  (setq brick (entlast))
  (command "-array" brick "" "R" "" (itoa cnt) (rtos step))

  ;; draw a single joint
  (setq mp1 (list (car p2) (cadr p1))
mp2 (list (+ (car p2) mjoin) (cadr p2))
)
  (setvar "cecolor" "9")
  (command "._rectang" mp1 mp2)
  (command "extrude" "L" "" cheight)
  ;; array   
  (setq sjoint (entlast))
  (command "-array"
   sjoint
   ""
   "_R"
   ""
   (itoa (1- cnt))
   (rtos step))

  ;; draw mortar joint by style

  (if (not mark) ; without overhangs
    (progn
      (setq jp1 lp
    jp2 (list (car lp) (+ (cadr lp) height))
    jp3 (list (car rp) (cadr jp2))
    jp4 (list (car jp3) (cadr jp1))
    jp5 (list (+ (car jp4) joint) (cadr jp4))
    jp6 (list (car jp5) (+ (cadr jp3) joint))
    jp7 (list (- (car jp1) joint) (cadr jp6))
    jp8 (list (car jp7) (cadr jp1))
    )

      (setq ptlist (list jp1 jp2 jp3 jp4 jp5 jp6 jp7 jp8))
      (entmake
(append
  (list
    '(0 . "LWPOLYLINE")
    '(100 . "AcDbEntity")
    '(8 . "0")
    '(100 . "AcDbPolyline")
    (cons 90 (length ptlist)) ;number of verticies
    (cons 70 1) ;closed
    (cons 62 9) ; color
    (cons 43 0.0) ;constant width
    )
  (mapcar '(lambda (x) (cons 10 x)) ptlist))

)
      (command "extrude" "L" "" cheight)
      )
                                  ;; with overhangs
    (progn
      (setq jp1 lp
    jp2 (list (car lp) (+ (cadr lp) height) (caddr lp))
    jp3 (list (car rp) (cadr jp2) (caddr lp))
    jp4 (list (car jp3) (cadr jp1) (caddr lp))
    jp5 (list (- (car jp4) overhang) (cadr jp4) (caddr lp))
    jp6 (list (car jp5) (- (cadr jp5) joint) (caddr lp))
    jp7 (list (+ (car rp) joint) (cadr jp6) (caddr lp))
    jp8 (list (car jp7) (+ (cadr jp5) joint height) (caddr lp))
    jp9 (list (- (car lp) joint) (cadr jp8) (caddr lp))
    jp10 (list (car jp9) (cadr jp6) (caddr lp))
    jp11 (list (+ (car jp1) overhang) (cadr jp6) (caddr lp))
    jp12 (list (car jp11) (cadr jp5) (caddr lp))
    )

      (setq ptlist (list jp1 jp2 jp3 jp4 jp5 jp6 jp7 jp8 jp9 jp10 jp11 jp11 jp12))
      (entmake
(append
  (list
    '(0 . "LWPOLYLINE")
    '(100 . "AcDbEntity")
    '(8 . "0")
    '(100 . "AcDbPolyline")
    (cons 90 (length ptlist)) ;number of verticies
    (cons 70 1) ;closed
    (cons 62 9) ; color
    (cons 43 0.0) ;constant width
    )
  (mapcar '(lambda (x) (cons 10 x))
  (mapcar '(lambda (y) (list (car y) (cadr y))) ptlist))
  )
)
      (command "extrude" "L" "" cheight)
      )
    )
  (command "._zoom" "_P")
  (setvar "osmode" 0)
  (setvar "cmdecho" 1)
  (command "._undo" "_E")
  (princ)
  )

~'J'~

One Shot

  • Guest
Re: How would you array this horizotally
« Reply #20 on: May 10, 2008, 11:29:04 AM »
~J~

How would I keep the mortar joints between the brick up against eachother instead have them over lap the brick on the right.

Rigjht now when I run the routine with the over hang, there is a small space between the left brick and the mortar joint.  The brick are in the correct position.

The routine work outstanding thou.

Brad

Fatty

  • Guest
Re: How would you array this horizotally
« Reply #21 on: May 10, 2008, 02:05:39 PM »
Yes, you're right :oops:
I'm a bad math, can you rewrite this
part by yourself?

~'J'~


One Shot

  • Guest
Re: How would you array this horizotally
« Reply #22 on: May 10, 2008, 05:10:39 PM »
I can rewrite that part.


Thank you,

Brad

Fatty

  • Guest
Re: How would you array this horizotally
« Reply #23 on: May 10, 2008, 05:35:27 PM »
Hi Brad,
I'll try to do it, but at the moment
I need to doing one of my own projects
This is extremely urgent work for me
 :|
~'J'~


One Shot

  • Guest
Re: How would you array this horizotally
« Reply #24 on: May 10, 2008, 09:28:00 PM »
Fatty,

I will rewrite that part.  I will ask you if I get stuck.

Thank you,

Brad

Fatty

  • Guest
Re: How would you array this horizotally
« Reply #25 on: May 11, 2008, 11:30:10 AM »
Hi Brad,
Try this one instead

Code: [Select]
(defun C:try  (/      brick  cheight    cnt   diff dist height joint  jp1    jp10   jp11   jp12   jp2 jp3
       jp4    jp5    jp6    jp7    jp8   jp9 leng lp     mark   mjoin  mp1    mp2    num   overhang
       p1     p2     ptlist response   rp sjoint step   width  x      y)

  (command "._undo" "_BE")
  (setvar "osmode" 0)
  (setvar "cmdecho" 0)
  (setq width 2.25
height 7.625
cheight 3.625
overhang 3.25
joint 0.375)
  (setvar "orthomode" 1)
  (setq lp (getpoint "\nPick point top left corrner of opening: ")
rp (getpoint lp "\nPick point top right corrner of opening: ")
)
  (initget "Yes No")
  (setq response (getkword
   "\nIs there an overhang beyond the opening or no opening?\n (Yes/No) <Y>: "))
  (if (not response)
    (setq response "Yes"))
  (if (eq "Yes" response)
    (progn
      (setq mark T)
      (setq lp (list (- (car lp) overhang) (cadr lp))
    rp (list (+ (car rp) overhang) (cadr rp))
    )
      )
    (setq mark nil)
    )

  (setq dist (distance (trans lp 0 1) (trans rp 0 1)))
  (setq cnt (fix (/ dist width)))
  (setq leng (* cnt width))
  (setq diff (- dist leng))

  (if (< diff 0)
    (progn
      (setq cnt (1- cnt))
      (setq leng (* cnt width))
      (setq diff (- dist leng))))
  (setq mjoin (/ diff (1- cnt)))

  ;; recalculate till the joint will have a desired size :
  (while (< mjoin 0.25)
    (progn
      (setq cnt (1- cnt))
      (setq leng (* cnt width))
      (setq diff (- dist leng)))
    (setq mjoin (/ diff (1- cnt))))
  (setq leng (+ (* cnt width) (* (1- cnt) mjoin)))

  ;; compare result with length of opening 
  (if (not (equal leng dist 0.001))
    (progn
      (princ "\nWrong result, you're the dumb, Fatty")
      (exit)
      (princ)
      )
    )
  ;; get the step of an array 
  (setq step (+ width mjoin))

  ;; draw a single brick
  (setq p1 (list (car lp) (cadr lp))
p2 (list (+ (car lp) width) (+ (cadr lp) height))
)

  (command "._zoom" "_W" p1 p2)
  (setvar "clayer" "0")
  (setvar "cecolor" "22")
  (command "._rectang" p1 p2)
  (command "extrude" "L" "" cheight)
  ;; array 
  (setq brick (entlast))
  (command "-array" brick "" "R" "" cnt step)

  ;; draw a single joint
  (setq mp1 (list (car p2) (cadr p1))
mp2 (list (+ (car p2) mjoin) (cadr p2))
)
  (setvar "cecolor" "9")
  (command "._rectang" mp1 mp2)
  (command "extrude" "L" "" cheight)
  ;; array   
  (setq sjoint (entlast))
  (command "-array"
   sjoint
   ""
   "_R"
   ""
   (1- cnt)
   step)

  ;; draw mortar joint by style

  (if (not mark) ; without overhangs
    (progn
      (setq jp1 lp
    jp2 (list (car lp) (+ (cadr lp) height))
    jp3 (list (car rp) (cadr jp2))
    jp4 (list (car jp3) (cadr jp1))
    jp5 (list (+ (car jp4) joint) (cadr jp4))
    jp6 (list (car jp5) (+ (cadr jp3) joint))
    jp7 (list (- (car jp1) joint) (cadr jp6))
    jp8 (list (car jp7) (cadr jp1))
    )

      (setq ptlist (list jp1 jp2 jp3 jp4 jp5 jp6 jp7 jp8))
      (entmake
(append
  (list
    '(0 . "LWPOLYLINE")
    '(100 . "AcDbEntity")
    '(8 . "0")
    '(100 . "AcDbPolyline")
    (cons 90 (length ptlist)) ;number of verticies
    (cons 70 1) ;closed
    (cons 62 9) ; color
    (cons 43 0.0) ;constant width
    )
  (mapcar '(lambda (x) (cons 10 x)) ptlist))

)
      (command "extrude" "L" "" cheight)
      )
                                  ;; with overhangs
    (progn
      (setq jp1 lp
    jp2 (list (car lp) (+ (cadr lp) height) (caddr lp))
    jp3 (list (car rp) (cadr jp2) (caddr lp))
    jp4 (list (car jp3) (cadr jp1) (caddr lp))
    jp5 (list (- (car jp4) overhang) (cadr jp4) (caddr lp))
    jp6 (list (car jp5) (- (cadr jp5) joint) (caddr lp))
    jp7 (list (+ (car rp) joint) (cadr jp6) (caddr lp))
    jp8 (list (car jp7) (+ (cadr jp5) joint height) (caddr lp))
    jp9 (list (- (car lp) joint) (cadr jp8) (caddr lp))
    jp10 (list (car jp9) (cadr jp6) (caddr lp))
    jp11 (list (+ (car jp1) overhang) (cadr jp6) (caddr lp))
    jp12 (list (car jp11) (cadr jp5) (caddr lp))
    )

      (setq ptlist (list jp1 jp2 jp3 jp4 jp5 jp6 jp7 jp8 jp9 jp10 jp11 jp11 jp12))
      (entmake
(append
  (list
    '(0 . "LWPOLYLINE")
    '(100 . "AcDbEntity")
    '(8 . "0")
    '(100 . "AcDbPolyline")
    (cons 90 (length ptlist)) ;number of verticies
    (cons 70 1) ;closed
    (cons 62 9) ; color
    (cons 43 0.0) ;constant width
    )
  (mapcar '(lambda (x) (cons 10 x))
  (mapcar '(lambda (y) (list (car y) (cadr y))) ptlist))
  )
)
      (command "extrude" "L" "" cheight)
      )
    )
  (command "._zoom" "_P")
  (setvar "osmode" 0)
  (setvar "cmdecho" 1)
  (command "._undo" "_E")
  (princ)
  )

~'J'~

deegeecees

  • Guest
Re: How would you array this horizotally
« Reply #26 on: May 11, 2008, 12:36:35 PM »
O.T....   7.625 is the diameter of an M16 round if I remember correctly.   :wink:

The M16A1 uses a 5.56 mm NATO round .
The M60, M14, AK47, 7.625mm Nato round.

D'oh! Been a while.

Gotta remember to groogle things before I post.

One Shot

  • Guest
Re: How would you array this horizotally
« Reply #27 on: May 11, 2008, 08:19:50 PM »
O.T....   7.625 is the diameter of an M16 round if I remember correctly.   :wink:

The M16A1 uses a 5.56 mm NATO round .
The M60, M14, AK47, 7.625mm Nato round.

D'oh! Been a while.

Gotta remember to groogle things before I post.
When were you in and what branch?

deegeecees

  • Guest
Re: How would you array this horizotally
« Reply #28 on: May 12, 2008, 10:21:03 AM »
86-89, U.S. Army, 55B Ammo Spec, 60th Ord Co., Friedburg Germany. I went stateside just before the wall came down in Berlin.

One Shot

  • Guest
Re: How would you array this horizotally
« Reply #29 on: May 16, 2008, 04:18:18 PM »
Here is my next step in this lisp routine.  How am I doing so far.