Jump to content

I'm being naive (Vectors image)


ghost tester

Recommended Posts

Is there a possibility to make an animation in .DCL using vector image?
in the example below I have three arrows, with which I can rotate the arrow according to the angle, when I type the angle in the edit_box for the rotate arrow?

 

 

(defun c:Test (  ) 
  (if
    (and
      (setq dcl (vl-filename-mktemp nil nil ".dcl"))
      (setq des (open dcl "w"))
      (foreach str
        '(
          "butt04 : button { width = 15; fixed_width = true; alignment = centered; height = 2.5; fixed_height = true; }"          
          "test : dialog"
          "{"
          "   label = \"Teste\";"
          "   spacer_1;"
          "  : text     { label = \"DCL image animation\"; alignment = left; }"
          "    spacer;"
          "   : boxed_column { label = \"Options arrows\";"
          "     : row {"
          "       : boxed_column { label = \"Arrows Angles\";"
          "         : row { : edit_box {edit_width = 5.0; edit_limit = 5.0; fixed_width = true; label = \"Angle Red  \"; key = \"Arrow01\"; } }"
          "         : row { : edit_box {edit_width = 5.0; edit_limit = 5.0; fixed_width = true; label = \"Angle Green\"; key = \"Arrow02\"; } }"
          "         : row { : edit_box {edit_width = 5.0; edit_limit = 5.0; fixed_width = true; label = \"Angle Cyan\"; key = \"Arrow03\"; } }"
          "   spacer;  }"
          "     : boxed_column"
          "     {"
          "       label = \"Preview\";"
          "       : row { : image_button { key = \"Img_arrows\"; width = 38; height = 17; fixed_width = true; fixed_height = true; alignment = centered; color = dialog_background; } }"
          "       spacer;"
          "     }"
          "    } }"
          "  ok_cancel;"
          "}"
          )
        (write-line str des)
      )
      (not (setq des (close des)))
      (< 0 (setq dch (load_dialog dcl)))
      (new_dialog "test" dch)
    )
    (progn
      (vectors "Img_arrows")
      (setq valor (start_dialog))
      (cond
        ((= valor 12) (exit))
      )
    )
  )
  (*error* nil)
)

(defun vectors ( key )
  (start_image key )
  (mapcar 'vector_image; Color 4
    (list 155 160 113)
    (list 161 156 114)
    (list 163 163 163)
    (list 165 165 165)
    (list   4   4   4)
  );mapcar
  (mapcar 'vector_image; Color 3
    (list 63  63 63)
    (list 64  64 64)
    (list 67 113 72)
    (list 73 114 68)
    (list  3   3  3)
  );mapcar
  (mapcar 'vector_image; Color 1
    (list 166 171 113)
    (list  57  62 114)
    (list 177 177 177)
    (list  51  51  51)
    (list   1   1   1)
  );mapcar
  (mapcar 'vector_image; Color 8
    (list 207 204 202 202 203 203 204 207 209 208 208 210 120 119 119 115 115 117 120 122 120  16 113)
    (list 107 103 103 103 112 112 112 109 112 108 108 103  22  26  22  17  17  17  21  17  22 114  17)
    (list 210 207 204 206 206 204 207 209 211 211 211 211 120 120 119 119 117 120 122 124 124 211 113)
    (list 103 107 103 108 108 112 109 112 112 112 103 103  26  26  26  22  17  21  17  17  17 114 212)
    (list   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8)
  );mapcar
  (end_image)
);defun

image.png.06a073cbbefa6c15fd3da49ef3f22789.png

 

 

 

 

Link to comment
Share on other sites

40 minutes ago, BIGAL said:

That is cool Lee for a situation like this show the result, in this case 4 lines.

image.png.60552d01e6ac78ce90a15724ed29f1a4.png




@BIGAL
Your method is interesting, but I'm trying to understand how I can apply the Lee Mac function in my case.

Link to comment
Share on other sites

Here, I think I managed this...

 

(defun c:DCL-Test ( / dcl des dch valor r g c )
  ;;Source : https://www.cadtutor.net/forum/topic/71064-im-being-naive-vectors-image/
  ;;Arrows animated by Marko Ribar, d.i.a. (architect)
  ;;25.08.2020.
  (setq r "45" g "135" c "315")
  (if
    (and
      (setq dcl (vl-filename-mktemp nil nil ".dcl"))
      (setq des (open dcl "w"))
      (foreach str
        '(
          "butt04 : button { width = 15; fixed_width = true; alignment = centered; height = 2.5; fixed_height = true; }"          
          "test : dialog"
          "{"
          "   label = \"Teste\";"
          "   spacer_1;"
          "  : text     { label = \"DCL image animation\"; alignment = left; }"
          "    spacer;"
          "   : boxed_column { label = \"Options arrows\";"
          "     : row {"
          "       : boxed_column { label = \"Arrows Angles\";"
          "         : row { : edit_box {edit_width = 5.0; edit_limit = 5.0; fixed_width = true; label = \"Angle Red  \"; key = \"Arrow01\"; mnemonic = \"R\"; } }"
          "         : row { : edit_box {edit_width = 5.0; edit_limit = 5.0; fixed_width = true; label = \"Angle Green\"; key = \"Arrow02\"; mnemonic = \"G\"; } }"
          "         : row { : edit_box {edit_width = 5.0; edit_limit = 5.0; fixed_width = true; label = \"Angle Cyan\"; key = \"Arrow03\"; mnemonic = \"C\"; } }"
          "   spacer;  }"
          "     : boxed_column"
          "     {"
          "       label = \"Preview\";"
          "       : row { : image_button { key = \"Img_arrows\"; width = 38; height = 17; fixed_width = true; fixed_height = true; alignment = centered; color = dialog_background; } }"
          "       spacer;"
          "     }"
          "    } }"
          "  ok_cancel;"
          "}"
        )
        (write-line str des)
      )
      (not (setq des (close des)))
      (> (setq dch (load_dialog dcl)) 0)
      (new_dialog "test" dch)
    )
    (progn
      (mapcar 'set_tile '("Arrow01" "Arrow02" "Arrow03") (list r g c))
      (action_tile "Arrow01" "(vectors_refresh \"Img_arrows\" r g c) (vectors \"Img_arrows\" (setq r $value) g c)")
      (action_tile "Arrow02" "(vectors_refresh \"Img_arrows\" r g c) (vectors \"Img_arrows\" r (setq g $value) c)")
      (action_tile "Arrow03" "(vectors_refresh \"Img_arrows\" r g c) (vectors \"Img_arrows\" r g (setq c $value))")
      (action_tile "Accept" "(done_dialog 1)")
      (action_tile "Cancel" "(done_dialog 0)")
      (vectors "Img_arrows" r g c)
      (setq valor (start_dialog))
    )
  )
  (setq dch (unload_dialog dch))
  (vl-file-delete dcl)
  (list valor r g c)
)

(defun vectors_refresh ( key r g c / d o da ro ro1 ro2 go go1 go2 co co1 co2 )
  (setq r (atof r) g (atof g) c (atof c))
  (setq d (sqrt (+ (expt 50 2) (expt 50 2))))
  (setq o (list 113 114))
  (setq da 10)
  (setq ro (polar '(0 0) (cvunit r "degree" "radian") d))
  (setq ro1 (polar ro (cvunit (+ r 150) "degree" "radian") da))
  (setq ro2 (polar ro (cvunit (+ r 210) "degree" "radian") da))
  (setq ro (list (car ro) (- (cadr ro))))
  (setq ro1 (list (car ro1) (- (cadr ro1))))
  (setq ro2 (list (car ro2) (- (cadr ro2))))
  (setq go (polar '(0 0) (cvunit g "degree" "radian") d))
  (setq go1 (polar go (cvunit (+ g 150) "degree" "radian") da))
  (setq go2 (polar go (cvunit (+ g 210) "degree" "radian") da))
  (setq go (list (car go) (- (cadr go))))
  (setq go1 (list (car go1) (- (cadr go1))))
  (setq go2 (list (car go2) (- (cadr go2))))
  (setq co (polar '(0 0) (cvunit c "degree" "radian") d))
  (setq co1 (polar co (cvunit (+ c 150) "degree" "radian") da))
  (setq co2 (polar co (cvunit (+ c 210) "degree" "radian") da))
  (setq co (list (car co) (- (cadr co))))
  (setq co1 (list (car co1) (- (cadr co1))))
  (setq co2 (list (car co2) (- (cadr co2))))
  (mapcar 'set '(ro ro1 ro2 go go1 go2 co co1 co2) (list (mapcar '+ o ro) (mapcar '+ o ro1) (mapcar '+ o ro2) (mapcar '+ o go) (mapcar '+ o go1) (mapcar '+ o go2) (mapcar '+ o co) (mapcar '+ o co1) (mapcar '+ o co2)))
  (start_image key)
  (mapcar 'vector_image; Color 4
    (list (fix (car co)) (fix (car co)) (car o))
    (list (fix (cadr co)) (fix (cadr co)) (cadr o))
    (list (fix (car co1)) (fix (car co2)) (fix (car co)))
    (list (fix (cadr co1)) (fix (cadr co2)) (fix (cadr co)))
    (list -15 -15 -15)
  );mapcar
  (mapcar 'vector_image; Color 3
    (list (fix (car go)) (fix (car go)) (car o))
    (list (fix (cadr go)) (fix (cadr go)) (cadr o))
    (list (fix (car go1)) (fix (car go2)) (fix (car go)))
    (list (fix (cadr go1)) (fix (cadr go2)) (fix (cadr go)))
    (list -15 -15 -15)
  );mapcar
  (mapcar 'vector_image; Color 1
    (list (fix (car ro)) (fix (car ro)) (car o))
    (list (fix (cadr ro)) (fix (cadr ro)) (cadr o))
    (list (fix (car ro1)) (fix (car ro2)) (fix (car ro)))
    (list (fix (cadr ro1)) (fix (cadr ro2)) (fix (cadr ro)))
    (list -15 -15 -15)
  );mapcar
  (end_image)
);defun

(defun vectors ( key r g c / d o da ro ro1 ro2 go go1 go2 co co1 co2 )
  (setq r (atof r) g (atof g) c (atof c))
  (setq d (sqrt (+ (expt 50 2) (expt 50 2))))
  (setq o (list 113 114))
  (setq da 10)
  (setq ro (polar '(0 0) (cvunit r "degree" "radian") d))
  (setq ro1 (polar ro (cvunit (+ r 150) "degree" "radian") da))
  (setq ro2 (polar ro (cvunit (+ r 210) "degree" "radian") da))
  (setq ro (list (car ro) (- (cadr ro))))
  (setq ro1 (list (car ro1) (- (cadr ro1))))
  (setq ro2 (list (car ro2) (- (cadr ro2))))
  (setq go (polar '(0 0) (cvunit g "degree" "radian") d))
  (setq go1 (polar go (cvunit (+ g 150) "degree" "radian") da))
  (setq go2 (polar go (cvunit (+ g 210) "degree" "radian") da))
  (setq go (list (car go) (- (cadr go))))
  (setq go1 (list (car go1) (- (cadr go1))))
  (setq go2 (list (car go2) (- (cadr go2))))
  (setq co (polar '(0 0) (cvunit c "degree" "radian") d))
  (setq co1 (polar co (cvunit (+ c 150) "degree" "radian") da))
  (setq co2 (polar co (cvunit (+ c 210) "degree" "radian") da))
  (setq co (list (car co) (- (cadr co))))
  (setq co1 (list (car co1) (- (cadr co1))))
  (setq co2 (list (car co2) (- (cadr co2))))
  (mapcar 'set '(ro ro1 ro2 go go1 go2 co co1 co2) (list (mapcar '+ o ro) (mapcar '+ o ro1) (mapcar '+ o ro2) (mapcar '+ o go) (mapcar '+ o go1) (mapcar '+ o go2) (mapcar '+ o co) (mapcar '+ o co1) (mapcar '+ o co2)))
  (start_image key)
  (mapcar 'vector_image; Color 4
    (list (fix (car co)) (fix (car co)) (car o))
    (list (fix (cadr co)) (fix (cadr co)) (cadr o))
    (list (fix (car co1)) (fix (car co2)) (fix (car co)))
    (list (fix (cadr co1)) (fix (cadr co2)) (fix (cadr co)))
    (list 4 4 4)
  );mapcar
  (mapcar 'vector_image; Color 3
    (list (fix (car go)) (fix (car go)) (car o))
    (list (fix (cadr go)) (fix (cadr go)) (cadr o))
    (list (fix (car go1)) (fix (car go2)) (fix (car go)))
    (list (fix (cadr go1)) (fix (cadr go2)) (fix (cadr go)))
    (list 3 3 3)
  );mapcar
  (mapcar 'vector_image; Color 1
    (list (fix (car ro)) (fix (car ro)) (car o))
    (list (fix (cadr ro)) (fix (cadr ro)) (cadr o))
    (list (fix (car ro1)) (fix (car ro2)) (fix (car ro)))
    (list (fix (cadr ro1)) (fix (cadr ro2)) (fix (cadr ro)))
    (list 1 1 1)
  );mapcar
  (mapcar 'vector_image; Color 8
    (list 207 204 202 202 203 203 204 207 209 208 208 210 120 119 119 115 115 117 120 122 120  16 113)
    (list 107 103 103 103 112 112 112 109 112 108 108 103  22  26  22  17  17  17  21  17  22 114  17)
    (list 210 207 204 206 206 204 207 209 211 211 211 211 120 120 119 119 117 120 122 124 124 211 113)
    (list 103 107 103 108 108 112 109 112 112 112 103 103  26  26  26  22  17  21  17  17  17 114 212)
    (list   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8)
  );mapcar
  (end_image)
);defun

 

Edited by marko_ribar
  • Thanks 1
Link to comment
Share on other sites

Very nice add your name or http link  take credit for a big effort.

 

This may be useful also

 

;**************************************************************************************
; VECTORIZE - Command to convert AutoCAD objects into 'lsp' functions to simplify     *
; =========   the placement of vector images within DCL image tiles and buttons.      *
;                                                                                     *
;             created by Richard Willis, (aka 'Didge', find me at 'www.theswamp.org') *

  • Like 1
Link to comment
Share on other sites

Very nice.

 

180 and 270 degrees don't quite line up on the axis (about 1 degree off) but that is being mega picky of me!

 

 

 

  • Like 1
Link to comment
Share on other sites

18 hours ago, ghost tester said:

If someone can make this animation for me I can pay $$
I've already debugged Lee's code But I can't replicate

My quickie demo.

Vector-Angles.gif.a010feac0db4d4ea971eb5a1dd0c607e.gif

  • Like 1
Link to comment
Share on other sites

15 hours ago, marko_ribar said:

Here, I think I managed this...

 

 

 

 

Very good   @marko_ribar 
That was what I needed! thank you very much.
I will send a message to make your payment.

 

Link to comment
Share on other sites

I've already disscussed about payment stuff with me with some other members... Please find something interesting you are working on : *.pdf, *.lsp or sometning equal value and post me as a gift at : ribarm@gmail.com . I can't accept money - banks takes almost all credits-provision, so this is not an option...

Edited by marko_ribar
Link to comment
Share on other sites

26 minutes ago, Tharwat said:

@ghost tester You need to add function vl-file-delete to delete the temporary file otherwise you will find your temporary folder is full of .dcl files each time you run the program.

 

A tip Lee had somewhere was to specify the temp file name, so in this case you might always create "vectorsimage.dcl" in the temporary file, which is overwritten each time it runs and won't fill up the temp directory (see I do pay attention sometimes).

Link to comment
Share on other sites

3 minutes ago, Steven P said:

 

A tip Lee had somewhere was to specify the temp file name, so in this case you might always create "vectorsimage.dcl" in the temporary file, which is overwritten each time it runs and won't fill up the temp directory (see I do pay attention sometimes).

I am talking about the posted codes above from the OP.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...