Results 1 to 10 of 10

Thread: Detach Image IF it exists

  1. #1
    AUGI Addict jpaulsen's Avatar
    Join Date
    2002-04
    Location
    Colorado
    Posts
    2,020
    Login to Give a bone
    0

    Default Detach Image IF it exists

    We have an image in many of our drawings that is a remnant of on old title block. I want to put something in my Acaddoc.lsp to detach the image if it exists. My only problem is I don't know how to determine if it exists.

    I put the following line in my Acaddoc.lsp:
    (command "-image" "d" "BW_JR_FORMAT_B")

    That works fine if the image exist but crashes if it does not. Well OK it doesn't "crash" but it displays the message Unknown command "BW_JR_FORMAT_B".

    How would I search the drawing to see if the image exists and how would I put the above line of code into an IF statement?

    Edit: If there is a better way to accomplish my goal I am more than willing to listen.

  2. #2
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043
    Login to Give a bone
    0

    Default Re: Detach Image IF it exists

    How comfortable are you with lisp and dictionaries? That is the way I would do it. Step through the 'ACAD_IMAGE_DICT' and see if your image is there, if so, erase it from the dictionary.

  3. #3
    AUGI Addict jpaulsen's Avatar
    Join Date
    2002-04
    Location
    Colorado
    Posts
    2,020
    Login to Give a bone
    0

    Default Re: Detach Image IF it exists

    Unfortunately I am not very familiar with dictionaries or lisp for that matter. I'm what I call a lisp hack.

    When I have more time I will do some research on accessing the dictionaries.

  4. #4
    AUGI Addict Railrose's Avatar
    Join Date
    2000-12
    Location
    Abilene, TX
    Posts
    1,181
    Login to Give a bone
    0

    Default Re: Detach Image IF it exists

    Quote Originally Posted by jpaulsen
    Unfortunately I am not very familiar with dictionaries or lisp for that matter. I'm what I call a lisp hack.

    When I have more time I will do some research on accessing the dictionaries.
    You can also do a CTRL + A to select everything, then CTRL + 1 to open the properties box. At the top left, is a pulldown. Click the arrow, & it will give you the option for Raster Image, if one exists. Can be slow to run on huge drawings, but is a quick & dirty way to see what is in the drawing file.
    Give people a job worth doing, the tools to do it, recognition of a job well done & get out of the way.

  5. #5
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,100
    Login to Give a bone
    0

    Default Re: Detach Image IF it exists

    Quote Originally Posted by drafter29
    You can also do a CTRL + A to select everything, then CTRL + 1 to open the properties box. At the top left, is a pulldown. Click the arrow, & it will give you the option for Raster Image, if one exists. Can be slow to run on huge drawings, but is a quick & dirty way to see what is in the drawing file.
    Jane,

    That is a good tip. However, Jeff is looking for an automated approach to removing the image.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  6. #6
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,100
    Login to Give a bone
    0

    Default Re: Detach Image IF it exists

    Quote Originally Posted by jpaulsen
    Unfortunately I am not very familiar with dictionaries or lisp for that matter. I'm what I call a lisp hack.

    When I have more time I will do some research on accessing the dictionaries.
    Jeff,

    Maybe the links in this post can help you on your journey to learning dictionaries.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  7. #7
    I could stop if I wanted to
    Join Date
    2015-08
    Posts
    263
    Login to Give a bone
    0

    Default Re: Detach Image IF it exists

    Quote Originally Posted by jpaulsen
    I put the following line in my Acaddoc.lsp:
    (command "-image" "d" "BW_JR_FORMAT_B")

    That works fine if the image exist but crashes if it does not. Well OK it doesn't "crash" but it displays the message Unknown command "BW_JR_FORMAT_B".

    How would I search the drawing to see if the image exists and how would I put the above line of code into an IF statement?
    Hi Jeff,
    This code won't display the irritating "Unknown command..." string.
    Code:
    (command "-image" "d")
    (if (= (getvar "cmdactive") 1)
      (command "BW_JR_FORMAT_B")
      (princ "\nNo images found in this drawing.") 
      )
    You may delete (princ "\nNo images found in this drawing.") if you don't want to see any prompt.

    Regards,
    Abdul Huck

  8. #8
    AUGI Addict jpaulsen's Avatar
    Join Date
    2002-04
    Location
    Colorado
    Posts
    2,020
    Login to Give a bone
    0

    Default Re: Detach Image IF it exists

    I ended up using the code posted by R.K. McSwain in this thread:
    http://discussion.autodesk.com/threa...sageID=5498183

  9. #9
    Certifiable AUGI Addict robert.1.hall72202's Avatar
    Join Date
    2004-07
    Location
    Detroit Michigan
    Posts
    2,508
    Login to Give a bone
    0

    Default Re: Detach Image IF it exists

    Is there a way to detach all images?

  10. #10
    AUGI Addict jpaulsen's Avatar
    Join Date
    2002-04
    Location
    Colorado
    Posts
    2,020
    Login to Give a bone
    0

    Default Re: Detach Image IF it exists

    Here is a modified version of Abdul's code that seems to work.

    Code:
    (defun c:test() 
    (command "-image" "d")
      (if (= (getvar "cmdactive") 1)
    	(command "*")
    	(princ "\nNo images found in this drawing.")
      )
    (princ)
    )

Similar Threads

  1. 2015: FAMILY ALREADY EXISTS
    By gordolake in forum Revit Architecture - General
    Replies: 2
    Last Post: 2014-08-26, 11:29 PM
  2. test if level exists
    By sfaust in forum Revit - API
    Replies: 44
    Last Post: 2012-01-11, 04:38 PM
  3. LISP to detach all XREF,PDF,IMAGE,ALL UNDERLAYS
    By sweichel in forum AutoLISP
    Replies: 21
    Last Post: 2011-07-05, 02:56 PM
  4. .png image will not detach!
    By Openwheeler in forum AutoCAD Map 3D - General
    Replies: 3
    Last Post: 2010-03-10, 04:39 PM
  5. napkin sketch still exists???
    By ccook.135811 in forum ACA General
    Replies: 1
    Last Post: 2007-10-16, 03:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •