Jump to content

Help : autocad dcl + vector image


Recommended Posts

Posted

Hi. In text calc lisp code LeeMac use    vector image

 

            (foreach x
             '(
                ("+"
                  (033 032 031 030 029 028 028 028 027 026 025 024 023 022 022 022 021 020 019 018 017 016 015 014 013 012 011 010 009 041 040 039 038
                   037 036 035 034)
                  (027 027 027 027 027 011 027 041 041 041 041 041 041 011 027 041 027 027 027 027 027 027 027 027 027 027 028 029 029 029 029 028 027
                   027 027 027 027)
                  (023 023 023 023 023 009 023 039 009 009 009 009 009 009 023 039 023 023 023 023 023 023 023 023 023 023 022 021 021 021 021 022 023
                   023 023 023 023)
                )
                ("-"
                  (037 036 035 034 033 032 031 030 029 028 027 026 025 024 023 022 021 020 019 018 017 016 015 014 013 012 011 010 009 041 040 039 038)
                  (027 027 027 027 027 027 027 027 027 027 027 027 027 027 027 027 027 027 027 027 027 027 027 027 027 027 028 029 029 029 029 028 027)
                  (023 023 023 023 023 023 023 023 023 023 023 023 023 023 023 023 023 023 023 023 023 023 023 023 023 023 022 021 021 021 021 022 023)
                )
                ("/"
                  (027 026 026 026 025 025 025 024 024 024 023 023 023 022 022 022 021 020 019 018 017 016 015 014 013 012 011 010 009 041 040 039 038
                   037 036 035 034 033 032 031 030 029 028 028 028 027 027)
                  (041 016 027 041 016 027 041 016 027 041 015 027 040 014 027 039 027 027 027 027 027 027 027 027 027 027 028 029 029 029 029 028 027
                   027 027 027 027 027 027 027 027 027 014 027 039 015 027)
                  (035 009 023 034 009 023 034 009 023 034 009 023 035 011 023 036 023 023 023 023 023 023 023 023 023 023 022 021 021 021 021 022 023
                   023 023 023 023 023 023 023 023 023 011 023 036 009 023)
                )
                ("*"
                  (027 026 025 024 023 022 022 021 021 020 020 019 019 018 018 017 017 016 016 015 015 014 014 013 013 012 012 011 011 040 040 039 039
                   038 038 037 037 036 036 035 035 034 034 033 033 032 032 031 031 030 030 029 029 028)
                  (030 029 028 029 030 025 031 024 032 023 033 022 034 021 035 020 036 019 039 018 040 017 039 016 038 016 037 016 036 015 035 016 036
                   016 037 016 038 017 039 018 040 019 037 020 036 021 035 022 034 023 033 024 032 031)
                  (020 021 022 021 020 019 025 018 026 017 027 016 028 015 029 014 030 010 031 010 032 011 033 012 034 013 034 014 034 015 035 014 034
                   013 034 012 034 011 033 010 032 013 031 014 030 015 029 016 028 017 027 018 026 019)
                )
)

 

 

I dont know how to do them and i dont know if is any programm to do this ,so with AI help i try to make 2 buttons for perantesis  ( and ) .

I get this code but if not parenthesis 

 

               ("("
                  (18 17 16 15 14 13 12 11 10  9  8  7  6  5  4)
                  (30 28 26 24 22 20 18 16 14 12 10  8  6  4  2)
                  (10 10 11 12 13 14 15 16 17 18 19 20 21 22 23)
                )		
                (")"
                  (4 5 6 7 8 9 10 11 12 13 14 15 16 17 18)
                  (30 28 26 24 22 20 18 16 14 12 10  8  6  4  2)
                  (10 10 11 12 13 14 15 16 17 18 19 20 21 22 23)
                )

 

Can any one help me ?

 

Thanks

Posted

As far as I remember the numbers are pairs of points,  in your '(' 18 ad 17, 16 and 15..... with the X coordinate to the left and Y to the TOP (unlike usual CAD where Y is counted from the bottom)

 

So your code has an odd number of numbers - I think they need an even number.

 

CAD is off for the evening now, but that might help.

 

You could also post the link to Lees code - usually there is an explanation in there, and also perhaps a screen shot of what you are getting or any errors.

  • Like 1
Posted
                ("("
                  (032 030 028 027 027 028 030 032)
                  (041 036 030 025 020 014 008 003)
                  (033 028 022 017 012 006 000 000)
                )
                (")"
                  (022 024 026 027 027 026 024 022)
                  (041 036 030 025 020 014 008 003)
                  (033 028 022 017 012 006 000 000)
                )

it is close now. Can any one fix it for me . I can not do it !!!  Thanks

Screenshot 2026-05-07 210044.png

Posted

Didn't someone have a lisp that created a menu system in model space ? on the right side of the current view.

  • Like 2
Posted

That would be The Dragon, RLX maybe? He had a menu but not sure if that is the one you're thinking off? (I was impressed but been too busy this year to get into using it)

  • Like 2
Posted

You could try these, the first one, test, will return lists for each line with the 4 values for the 2 end points (x1, y1, x2, y2). You need to also select a reference point to measure these points to. I tend to draw the thumbnail in a 75x75 square, reference point is top left corner and all the thumbnail entities are lines - nothing else - function name test

 

The second one I haven't adjusted, copied straight from my library, blockthumbrecord, select the lines, select the reference point and it will return some results in a new notepad window... so not been adjusted you might need to add a function in there (LM: functions from Lee Macs website). Also the notepad will add in other stuff that is handy for me - a good learning exercise to look at the code and adjust it so it works for you.

 

Both will give you sets of points for each line in a selection which you can copy and paste for your needs.

 

 

Note that the vector graphics cannot do fractions, so maybe best set your snaps and grid to '1' and to get a smooth curve, a few short lines and make sure that the ends all touch.

 

 

 

(defun c:test ( / )
  (defun LM:round ( n )
    (fix (+ n (if (minusp n) -0.5 0.5)))
  )

  (princ "\nSelect LINES for thumbnail: ")
;;Get entities
  (setq ss (ssget '((0 . "LINE"))))
  (if (not ss) ;check for nil selection set
    (progn
      (princ "Nothing selected.")
      (exit)
    ) ;end progn
  ) ;end if

;;get list of entities
  (setq LinesList (list))
  (setq acount 0)
  (setq BasePoint (getpoint "\Select Top Left Corner of Tumbnail (75x75 square)"))
  (setq BasePoint (reverse (cdr (reverse BasePoint))))
  (while (< acount (sslength ss))      ;loop for every entity in the set
    (setq en (ssname ss acount))       ;get entity name
    (setq ed (entget en))              ;get entity definition
    (setq pt1 (reverse (cdr (reverse (cdr (assoc 10 ed)))))) ;; X and Y only
    (setq pt1 (mapcar '- BasePoint pt1)) ;; Shift by basepoint
    (setq pt1 (mapcar 'LM:round (mapcar 'abs pt1))) ;; Absolute value rounded to nearest 1
    (setq pt1 (list (rtos (car pt1) 2 0) (rtos (cadr pt1) 2 0) )) ;; List items to strings
    (setq pt2 (reverse (cdr (reverse (cdr (assoc 11 ed)))))) ;; X and y Only
    (setq pt2 (mapcar '- BasePoint pt2)) ;; Shift by basepoint
    (setq pt2 (mapcar 'LM:round (mapcar 'abs pt2))) ;; Absolute value rounded to nearest 1
    (setq pt2 (list (rtos (car pt2) 2 0) (rtos (cadr pt2) 2 0) )) ;; List items to strings
    (setq pt1 (append pt1 pt2)) ;; Create thumbnail definition line
    (setq LinesList (append LinesList (list pt1)) ) ;; Add definition line to thumb. definition
    (setq acount (+ acount 1))
  ) ;;end while
  LinesList
)

 

 

 

 

 

(defun c:blockThumbrecord ( / ss LinesList acount en ed pt1 pt2 tempblock f )
;;Opens notepad wth lines coordinates
  (defun LM:lst->str ( lst del / str )
    (setq str (car lst))
    (foreach itm (cdr lst) (setq str (strcat str del itm)))
    str
  )

;;Get entities
  (setq ss (ssget '((0 . "LINE"))))
  (if (not ss) ;check for nil selection set
    (progn
      (princ "Nothing selected.")
      (exit)
    ) ;end progn
  ) ;end if

;;get list of entities
  (setq LinesList (list))
  (setq acount 0)
  (while (< acount (sslength ss))      ;loop for every entity in the set
    (setq en (ssname ss acount))       ;get entity name
    (setq ed (entget en))              ;get entity definition
    (setq pt1 (cdr (assoc 10 ed)))
    (setq pt1 (list "list" (rtos (abs (car pt1)) 2 0) (rtos (abs (cadr pt1)) 2 0) ))
    (setq pt2 (cdr (assoc 11 ed)))
    (setq pt1 (append pt1 (list (rtos (abs (car pt2)) 2 0) (rtos (abs (cadr pt2)) 2 0) "TxCol")))
    (setq LinesList (append LinesList (list pt1)) )
    (setq acount (+ acount 1))
  ) ;;end while

;;write to a temp file
  (if (strcat (getvar "TEMPPREFIX") "Thumbnail.txt")(vl-file-delete (strcat (getvar "TEMPPREFIX") "Thumbnail.txt")))
  (setq tempblock (strcat (getvar "TEMPPREFIX") "Thumbnail.txt")) ;;add check if this exists
  (setq f (open tempblock "w")) ;;open file


  (write-line "  (Defun Sel--**FUNCTIONNAME**-- ( origin BgCol TxCol ImgTile Control / BlkList return) " f)
  (write-line "    (if (= Control \"Vector\") " f)
  (write-line "      (progn " f)
  (write-line "        (start_image ImgTile) " f)
  (write-line "        (fill_image (- origin 0) 0 (+ origin 85) 85 BgCol) " f)
  (write-line "        (setq BlkList (list " f)
  (setq acount 0)
  (while (< acount (length LinesList))
    (write-line (strcat "(" (LM:lst->str (nth acount LinesList) " ") ")" )  f)
    (setq acount (+ acount 1))
  )
  (write-line "        )) ; end setq end list" f)

  (write-line "        (setq Xoff 0)(setq YOff 0)"  f)
  (write-line "        (CreateVector BlkList XOff YOff TxCol)"  f)
  (write-line "        (end_image)"  f)
  (write-line "        ); end progn"  f)
  (write-line "      (setq Return \"--**FUNCTION NAME TO INSERT BLOCK**--\")"  f)
  (write-line "    ) ; end if"  f)
  (write-line "  )"  f)

  (write-line "" f)
  (write-line ";  -OK-  ;" f) 

  (close f)

;;open notepad & file
;;  (startapp "c:/windows/notepad.exe" tempblock)		
    (vl-catch-all-apply
      (function
        (lambda ()
          (setq obj (vlax-get-or-create-object "WScript.Shell"))
          (vlax-invoke obj 'Run (strcat "c:/windows/notepad.exe \"" tempblock "\"")) ;; or notepad++ if that is used.
          (setvar 'cmdecho 0)
          (vlax-invoke obj 'AppActivate "Notepad") ; Title bar name of application. ++ for notepad++ but still works?
        )
      )
    )
    (if obj (vlax-release-object obj))
  (princ)
)

 

 

 

These should make it possible to easily get the coordinates to make something like this as a thumbnail: 

 

image.png.e008e975cb7047ce9323723631b35fcb.png

 

 

(The Engineers keep asking me to add a legend.... so I do)

The second LISP makes up the code I need for my block selection routine, thumbnail graphic, saved in the code, see the image I like, click and paste

  • Like 1
Posted

Thanks but, Nothing working for me. I have fount too the Vectorize lisp but i can not understand how works. when i go to Preview aske to select a lisp and I can not understand what to do !!!!!!!!!!!

Posted

So if I plot your points as pairs this is what I see (mirrored them to account for Y counting downwards)

 

image.png.53382983a66fda8f699b4ea7e463f257.png

 

I might have done something wrong though.

 

For a simple ')' try these values

 

(list 4 55 0 60 7)
(list 10 36 4 55 7)
(list 10 24 10 36 7)
(list 4 5 10 24 7)
(list 0 0 4 5 7)

 

and the other way:

(list 4 55 0 60 7)
(list 10 36 4 55 7)
(list 10 24 10 36 7)
(list 4 5 10 24 7)
(list 0 0 4 5 7)

 

Where using the function Vector_image the values in the list are X1, Y1, X2, Y2, Colour.

 

These are set for a 75x75 pixel square

 

 

 

Posted

Plenty of instructions on both links I posted, please explain exactly what you are struggling with and exactly what you are trying to accomplish.

 

GetVectors has a complete DOC file.

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...