Author Topic: Cliping and export image file  (Read 1816 times)

0 Members and 1 Guest are viewing this topic.

PM

  • Guest
Cliping and export image file
« on: June 02, 2021, 03:34:13 AM »
Hi. I am using maps in my job and always i use Photoshopo to clip them and then insert the clip image in autocad .I do this because i dont want to have big files. I know the imageclim command but i was thinking ....Is it possible to clim image in Autocad and export and remame as a new image only the cliping part ?

Thanks

mhupp

  • Bull Frog
  • Posts: 250
Re: Cliping and export image file
« Reply #1 on: June 02, 2021, 10:55:42 AM »
I don't think that is possible. Imageclip isn't doing what you think it does. All its doing is hiding parts of the image you don't want to see all the information is still there. it doesn't edit the image, you can run imageclip again and use the delete boundary command and it will return the image back to original. This isn't a magical  uncrop command

Rod

  • Newt
  • Posts: 185
Re: Cliping and export image file
« Reply #2 on: June 10, 2021, 06:43:55 PM »
Hey PM

If you were going to try to roll you own I would have a look at https://imagemagick.org/script/download.php#windows

Andrea wrote something that manipulates images and he may be able to help https://www.theswamp.org/index.php?topic=48080.msg531267#msg531267but I don't think he ever published it.

Cheers, Rod.
"All models are wrong, some models are useful" - George Box

d2010

  • Bull Frog
  • Posts: 322
Re: Cliping and export image file
« Reply #3 on: June 11, 2021, 05:33:02 AM »
You crop the big.jpg, (with Photoshop) only you need to duplicate the same-pixels
in JobDrawing.dwg.  If you crop to Clip , in the future(nextYear), you you cannot adjust and rescale your bigJpg.
I recommand , you use  Photogrammetric.arx https://youtu.be/2sJU5ODI9sY.
{--} If you need the kit then I can send to you, the kit.
 8-)
Hi. I am using maps in my job and always i use Photoshopo to clip them and then insert the clip image in autocad .I do this because i dont want to have big files. I
Thanks

VovKa

  • Water Moccasin
  • Posts: 1621
  • Ukraine

PM

  • Guest
Re: Cliping and export image file
« Reply #5 on: June 11, 2021, 04:48:36 PM »
Can i ask something else. I use this code to clip images. I it possible if i have a rectangle and not a polyline to clip the image as rectangular ?  like IMAGECLIP -> RECTANGULAR  an not as polyline

Code - Auto/Visual Lisp: [Select]
  1. ;;;CADALYST 10/06   Tip2151: ximageclip.lsp   Image Clip Using Lightweight Polyline    (c) Pedro Ferreira
  2.  
  3. ;;;Author: Pedro Miguel da Silva Ferreira       Email:pedro_ferreira@netcabo.pt or pferreira@wsatkins.pt
  4. ;;;Web page: http:pwp.netcabo.pt/pedro_ferreira
  5. ;;;Location: Portugal, Lisboa
  6. ;;;RDS: PMSF
  7. ;;;Command Name: xic
  8. ;;;Date: 16 of June 2006
  9. ;;;Version: 1.0
  10. ;;;Description: Visual Lisp Routine that creates a new clipping boundary for an image object by selecting a lwpolyline.
  11.  
  12.  
  13. (defun activexsupport ()
  14.   (setq *modelspace*
  15.          (vla-get-modelspace
  16.          )
  17.   )
  18. )
  19.  
  20. (defun getraster ()
  21.   (setq raster nil)
  22.   (while (= raster nil)
  23.     (progn
  24.       (setq raster (car (entsel "\nSelect the image to clip:")))
  25.       (if (/= raster nil)
  26.         (progn
  27.           (setq chkraster (cdr (assoc '0 (entget raster))))
  28.           (if (/= chkraster "IMAGE")
  29.             (setq raster nil)
  30.             (setq raster (vlax-ename->vla-object raster))
  31.           )
  32.         )
  33.       )
  34.     )
  35.   )
  36. )
  37.  
  38. (defun getpoly ()
  39.   (setq poly nil)
  40.   (while (= poly nil)
  41.     (progn
  42.       (setq poly (car (entsel "\nSelect a Polyline:")))
  43.       (if (/= poly nil)
  44.         (progn
  45.           (setq chkpoly (cdr (assoc '0 (entget poly))))
  46.           (if (/= chkpoly "LWPOLYLINE")
  47.             (setq poly nil)
  48.             (setq poly (vlax-ename->vla-object poly))
  49.           )
  50.         )
  51.       )
  52.     )
  53.   )
  54. )
  55.  
  56. (defun getcoordvariant ()
  57.   (setq coordvariante
  58.          (vlax-safearray->list
  59.            (vlax-variant-value
  60.              (vlax-get-property poly "coordinates")
  61.            )
  62.          )
  63.   )
  64.   (setq xyini (list (car coordvariante) (cadr coordvariante)))
  65.   (setq
  66.     coord (reverse (append (reverse xyini) (reverse coordvariante)))
  67.   )
  68.   (setq arraySpace
  69.          (vlax-make-safearray
  70.            vlax-vbdouble
  71.            (cons 0
  72.                  (- (length coord) 1)
  73.            )
  74.          )
  75.   )
  76.   (setq coordvariante
  77.          (vlax-make-variant
  78.            (vlax-safearray-fill arraySpace coord)
  79.          )
  80.   )
  81.  
  82.  
  83. )
  84.  
  85. (defun clipbound ()
  86.   (vla-clipboundary raster coordvariante)
  87.   (vlax-invoke-method raster 'clipboundary coordvariante)
  88. )
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95. (defun c:xic ()
  96.   (activexsupport)
  97.   (getraster)
  98.   (getpoly)
  99.   (getcoordvariant)
  100.   (clipbound)
  101.   (princ)
  102. )
  103.  
  104.   "Type [xic] in the command line\n\nAuthor: Pedro Ferreira\nweb page: http://pwp.netcabo.pt/pedro_Ferreira\n\nTHIS PROGRAM IS PROVIDED \"AS IS\" AND WITH ALL FAULTS.\n\nPress OK to continue."
  105. )
  106.  
  107.  
  108.  

Thanks

BIGAL

  • Swamp Rat
  • Posts: 1392
  • 40 + years of using Autocad
Re: Cliping and export image file
« Reply #6 on: June 11, 2021, 07:49:52 PM »
A rectang is a ployline, so where it asks for poly line change that part to say make rectang then use (entlast) so select it.

(setq poly (car (entsel "\nSelect a Polyline:")))
(setq poly (entlast))

It may work if you draw rectang then run lisp.
A man who never made a mistake never made anything

PM

  • Guest
Re: Cliping and export image file
« Reply #7 on: June 12, 2021, 02:33:51 AM »
Hi Bigal. And without

Code - Auto/Visual Lisp: [Select]
  1. (setq poly (car (entsel "\nSelect a Polyline:")))
  2. (setq poly (entlast))

cut rectangle but the image does not behave like  IMAGECLIP -> RECTANGULAR . when I select the  image and try to transform it behave  like a polyliline (move image edges to any direction) and not as rectangle (to move each side to any direction)

Thanks

BIGAL

  • Swamp Rat
  • Posts: 1392
  • 40 + years of using Autocad
Re: Cliping and export image file
« Reply #8 on: June 13, 2021, 07:52:25 PM »
Draw a rectang then (setq poly (entlast)) only. Not tested.
A man who never made a mistake never made anything

PM

  • Guest
Re: Cliping and export image file
« Reply #9 on: June 14, 2021, 10:05:57 AM »
I try it but nothing. Perhaps i did something wrong

mhupp

  • Bull Frog
  • Posts: 250
Re: Cliping and export image file
« Reply #10 on: June 15, 2021, 08:41:03 AM »
Seems to be working for me.  Might want to add the rectangle command right before you call the (getpoly) so its the last entity. 

Code: [Select]
(defun c:xic ()
  (activexsupport)
  (getraster)
  (vl-cmdf "_.Rectangle" pause pause)
  (getpoly)
  (getcoordvariant)
  (clipbound)
  (princ)
)

Code: [Select]
(defun getpoly ()
  (setq poly nil)
  (while (= poly nil)
    (progn
      (setq poly (entlast))
      (if (/= poly nil)
        (progn
          (setq chkpoly (cdr (assoc '0 (entget poly))))
          (if (/= chkpoly "LWPOLYLINE")
            (setq poly nil)
            (setq poly (vlax-ename->vla-object poly))
          )
        )
      )
    )
  )
)