Author Topic: Send images to back (Model only)  (Read 3256 times)

0 Members and 1 Guest are viewing this topic.

w64bit

  • Newt
  • Posts: 78
Send images to back (Model only)
« on: April 22, 2017, 11:49:31 AM »
I am using
(if (setq img (ssget "_X" '((0 . "IMAGE"))))(command "_DRAWORDER" img "" "_BACK"))
to send images to back, but I want to select only images in model space.
What code should I add?
Thank you.

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: Send images to back (Model only)
« Reply #1 on: April 22, 2017, 11:58:13 AM »
Add (410 . "Model") to the ssget filter list.

w64bit

  • Newt
  • Posts: 78
Re: Send images to back (Model only)
« Reply #2 on: April 22, 2017, 12:20:54 PM »
Thank you.

One more question.
I am using the code for IMAGE and GEOMAPIMAGE.
Are they any other types of image or raster except these?


Grrr1337

  • Swamp Rat
  • Posts: 812
Re: Send images to back (Model only)
« Reply #3 on: April 22, 2017, 12:22:08 PM »
One more question.
I am using the code for IMAGE and GEOMAPIMAGE.
Are they any other types of image or raster except these?

You could do this:
Code: [Select]
(0 . "*IMAGE*")
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg

w64bit

  • Newt
  • Posts: 78
Re: Send images to back (Model only)
« Reply #4 on: April 22, 2017, 12:37:20 PM »
I am using
(0 . "IMAGE")
and
(0 . "GEOMAPIMAGE")

Is there any other type of image/raster available?

mailmaverick

  • Bull Frog
  • Posts: 494
Re: Send images to back (Model only)
« Reply #5 on: April 27, 2017, 11:19:57 AM »
As posted by Grrr1337, instead of using (0 . "IMAGE") and (0 . "GEOMAPIMAGE") separately and worrying about any other type of image / raster, simply use (0 . "*IMAGE*") which will cover all types of images.
Notice the asterick (*) before and after IMAGE. When you use the * character at the beginning and end of the search pattern, you can locate the desired portion anywhere in the string.

For further help, visit following link :-

https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2016/ENU/AutoCAD-AutoLISP/files/GUID-E8328DF6-43FF-47AA-8524-72B962A9D552-htm.html

Willie

  • Swamp Rat
  • Posts: 958
  • Going nowhere slowly
Re: Send images to back (Model only)
« Reply #6 on: May 03, 2017, 03:01:14 PM »
Here is my code...

Code: [Select]
(defun c:I2B (/)
  (setvar "cmdecho" 0)
  (setq SS_IMAGE nil)
  (setq SS_IMAGE (ssget "X" '((0 . "IMAGE"))))
  (if (= SS_IMAGE nil)
    (princ "\nNo images in drawing")

    (progn
      (command "draworder" SS_IMAGE "" "back" )
      (setvar "cmdecho" 1)
      (princ "\n ************************************")
      (princ "\n *** All IMAGES  moved to back !! ***")
      (princ "\n ************************************")
      );progn
    );if
  (princ)
);defun


Add (410 . "Model") to the ssget filter list.

I will add this - Thanks Lee! 
Soli Deo Gloria | Qui Audet Adipiscitur
Windows 8  64-bit Enterprise | Civil 3D 2015 and 2016| ArcGIS 10.1
Yogi Berra : "I'd give my right arm to be ambidextrous."

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Send images to back (Model only)
« Reply #7 on: May 04, 2017, 04:36:44 PM »
Here's my version (includes hatch, pdf, ole, images)...

Code: [Select]
(defun c:HAB (/) (c:HIB))
(defun c:HIB (/ *error* _catch u lock e s ss i lst r)
  ;; send all Hatch and Images Back (draworder)
  ;; Alan J. Thompson, 12.23.10 | 2016.09.09

  (defun *error* (msg)
    (foreach l lock (vla-put-lock l :vlax-true))
    (if r
      (vla-regen *AcadDoc*
                 (if (eq (getvar 'CVPORT) 1)
                   acAllViewports
                   acActiveViewport
                 )
      )
    )
    (and u (vla-endundomark *AcadDoc*))
    (if (and msg (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*QUIT*,")))
      (progn (vl-bt) (princ (strcat "\nError: " msg)))
    )
  )


  (defun _catch (f a / r)
    (if (not (vl-catch-all-error-p (setq r (vl-catch-all-apply f a))))
      r
    )
  )



  (setq u (not (vla-startundomark
                 (cond (*AcadDoc*)
                       (setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object)))
                 )
               )
          )
  )

  (vlax-for lay (vla-get-layers *AcadDoc*)
    (if (eq (vla-get-lock lay) :vlax-true)
      (vla-put-lock (car (setq lock (cons lay lock))) :vlax-false)
    )
  )

  (setq e (vla-getextensiondictionary (vla-get-modelspace *AcadDoc*))
        s (cond ((_catch 'vla-getobject (list e "acad_sortents")))
                ((_catch 'vla-getobject (list e "acad_sortents" "acdbsortentstable")))
          )
  )

  (foreach pair '((0 . "HATCH") (0 . "IMAGE,OLE2FRAME,PDFUNDERLAY"))
    (if (setq ss (ssget "_X" (list pair '(410 . "Model"))))
      (progn

        (repeat (setq i (sslength ss))
          (setq lst (cons (vlax-ename->vla-object (ssname ss (setq i (1- i)))) lst))
        )

        (vlax-invoke s 'MoveToBottom lst)

        (setq r   t
              lst nil
        )
      )
    )
  )

  (*error* nil)
  (princ)
)
(vl-load-com)
(princ)
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: Send images to back (Model only)
« Reply #8 on: May 04, 2017, 06:12:12 PM »
You may also be interested in these resources:

Draw Order Functions
Draw Order Reactor

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Send images to back (Model only)
« Reply #9 on: May 05, 2017, 11:30:46 AM »
You may also be interested in these resources:

Draw Order Reactor
Pretty slick.
Something to consider is accounting for hatch atop other hatch - which I have yet to account for in my routine, but it does come up.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Grrr1337

  • Swamp Rat
  • Posts: 812
Re: Send images to back (Model only)
« Reply #10 on: May 05, 2017, 12:16:01 PM »
I'm using this, while attaching images - so I could draw over them:

Code - Auto/Visual Lisp: [Select]
  1. (foreach rtr (cdar (vlr-reactors :vlr-Command-reactor)) (if (= "FadeAttach" (vlr-data rtr)) (vlr-remove rtr)) )
  2.  
  3. (defun C:FadeAttachOn nil
  4.   (cond
  5.     ( (not FadeAttach:CB) (alert "\nFadeAttach:CB function not defined!") )
  6.     (T
  7.       (cond
  8.         ( (vl-some '(lambda (r) (= "FadeAttach" (vlr-data r))) (cdar (vlr-reactors :vlr-Command-reactor))) )
  9.         (T (vlr-Command-reactor "FadeAttach" '((:vlr-commandEnded . FadeAttach:CB))) )
  10.       ); cond
  11.       (alert "\nFade Attach Reactor enabled! \nNow the attached images would be send to back and faded by 80%." )
  12.       (defun C:FadeAttachOff nil
  13.           (if (= "FadeAttach" (vlr-data rtr)) (vlr-remove rtr))
  14.         ); foreach
  15.         (alert "\nFade Attach Text Reactor disabled!") (princ)
  16.       ); defun C:FadeAttachOff
  17.     )
  18.   ); cond
  19.   (princ)
  20. ); defun C:FadeAttachOn
  21.  
  22.  
  23. (defun FadeAttach:CB ( rtr args / e o )
  24.   (and
  25.     (member (car args) '("ATTACH" "XATTACH" "DWFATTACH" "IMAGEATTACH" "PDFATTACH" "POINTCLOUDATTACH" "COORDINATIONMODELATTACH"))
  26.     (setq e (entlast)) (setq o (vlax-ename->vla-object e))
  27.     (eq (vla-get-ObjectName o) "AcDbRasterImage") (vlax-property-available-p o 'Fade) (vlax-write-enabled-p o)
  28.     (progn
  29.       (vla-put-Fade o 80)
  30.       (vl-catch-all-apply
  31.         (function
  32.           (lambda ( / )
  33.             (vlax-invoke
  34.               (vla-AddObject
  35.                 "ACAD_SORTENTS" "AcDbSortentsTable"
  36.               )
  37.               'MoveToBottom (list o)
  38.             )
  39.           )
  40.         )
  41.       ); vl-catch-all-apply
  42.     ); progn
  43.   ); and
  44.   (princ)
  45. ); defun
  46.  

And I took the list of the "*ATTACH*" commands from Roy's code.
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg