Page 1 of 6 12345 ... LastLast
Results 1 to 10 of 52

Thread: searching a source DWG.

  1. #1
    Member
    Join Date
    2004-08
    Posts
    6
    Login to Give a bone
    0

    Default searching a source DWG.

    I know there is a way to do this but I am not sure what commands I should use. I know it would be some (vlax-XXX) command or the souch but I am not to familiar with those can someone point me inthe right direction?

    I want to insert a block into a drawing. But here is the hard part. These blocks change on a weekly basis. I want to scan a file and if the block I am looking for is there I want to insert that block if it is not there then I want to insert the block from my archive set.
    basically

    (if
    (test to see if block in source drawing) ;test
    (insert block from source);then
    (insert block from file);else
    );if

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

    Default Re: searching a source DWG.

    Do you mean inserted into the drawing, as in placed in the drawing? or that the block is in the drawing, but maybe not placed IN the drawing?
    To see if one is inserted in the drawing, I use
    Code:
    (if (setq ss (ssget "x" '((0 . "INSERT") (2 . "BLOCKNAME"))))
    .. do your stuff here
    )
    But if you just want to see if it is defined within the drawing, then I would use
    Code:
    (if (tblsearch "block" "blockname")
    ... do your stuff here
    )
    Hope that helps.

  3. #3
    Member
    Join Date
    2004-08
    Posts
    6
    Login to Give a bone
    0

    Default Re: searching a source DWG.

    Sorry, I think I may have been a little unclear. The source drawing to search for the block is called "Drawing1" and the block will be called "block1" the drawing I am working in we will call "Drawing2" I have drawing2 open and want to make a command that prompts the user for a block and then inserts the correct block. That is fine and dandy and working great. however now I have been asked to scan drawing1, which is not currently open, and if block1 is there use the block1 from drawing1 rather than block1 from my library. I know we could use the design center for this but some of the drafters have issues with that and I want to create something that requires less thought on their part. Thanks.

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

    Default Re: searching a source DWG.

    You will have to use ObjectDBX, and then the ActiveX controls to search that drawings block collection (table) to see if the block is there, and if so use the CopyObjects method of that block to copy it to the current drawing. Have you ever done anything like that? I think there are some examples here, but I'm not sure. I would search for ObjectDBX, and read those to get a good start. Post if you get stuck.

  5. #5
    Member
    Join Date
    2004-08
    Posts
    6
    Login to Give a bone
    0

    Default Re: searching a source DWG.

    Do you mean ObjectArx?!?

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

    Default Re: searching a source DWG.

    Nope. ObjectDBX will let you open a drawing, without opening it in the editor, and do things to it with ActiveX controls. ObjectARX is a more complex programing language that I know nothing about.

  7. #7
    All AUGI, all the time
    Join Date
    2015-12
    Location
    Central Oregon
    Posts
    591
    Login to Give a bone
    0

    Default Re: searching a source DWG.

    Joshua,
    Have a look at THIS The document posted there has a good description of what you are wanting to do.

    Jeff

  8. #8
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: searching a source DWG.

    Quote Originally Posted by joshua.andersen
    Do you mean ObjectArx?!?

    Hi Josh, try this one as an example for more understanding about ObjectDBX
    This routine copy defined block by user in command line by name from
    choosen library folder you need, search this block through all of files in this
    folder and then adds this block into block collection of a current drawing
    A2005 only

    Thank you

    f.
    Code:
    ;; written by Fatty T.O.H (c) 2004 
    ;; all rights removed 
    ;; get ObjectDBX document 
    
    (defun odbx-test (/ dbx_doc)
    (if (< (atof (getvar "ACADVER")) 15.06)
    (progn (alert "ObjectDBX method not applicable\nin this AutoCAD version")
      (exit)(princ)(gc))
    (progn
    (if (= (atoi (getvar "ACADVER")) 15)
    (progn
      
    (if (not (vl-registry-read
    "HKEY_CLASSES_ROOT\\ObjectDBX.AxDbDocument\\CLSID"))
    (startapp "regsvr32.exe"
    (strcat "/s \"" (findfile "axdb15.dll") "\"")))
    
    (setq dbx_doc (vla-getinterfaceobject
    (vlax-get-acad-object)
    "ObjectDBX.AxDbDocument")))
    
    (setq dbx_doc (vla-getinterfaceobject
                (vlax-get-acad-object)
                "ObjectDBX.AxDbDocument.16"))))))
    
    ;; main programm :
    
    (defun C:BFD (/		acapp	  adoc	    blk_col   bname
    	      cert_blk	fn	  fname	    fold      full_name_list
    	      mdmod	odbx	  x
    	     )
      (vl-load-com)
      (or acapp
          (setq acapp (vlax-get-acad-object))
      )
      (or adoc
          (setq adoc (vla-get-activedocument acapp))
      )
    
      (vla-endundomark adoc)
      (vla-startundomark adoc)
      (setq mdmod (vla-getvariable adoc "SDI"))
      (vla-setvariable
        adoc
        "SDI"
        (vlax-make-variant 0 vlax-vbinteger)
      )
      (setq odbx (odbx-test))
      (setq bname (getstring T "\nEnter block name to find (case-sensitive) : \n"))
      (setq	fn	       (getfiled "Select ANY \".dwg\" file to find block"
    				 ""
    				 "dwg"
    				 16
    		       )
    	fold	       (vl-filename-directory fn)
    	full_name_list (vl-directory-files fold "*.dwg" 1)
    	full_name_list (mapcar (function (lambda (x)
    					   (strcat fold "\\" x)
    					 )
    			       )
    			       full_name_list
    		       )
      )
      (foreach other full_name_list
        (if
          (setq fname (findfile other))
           (progn
    	 (vla-open odbx fname)
    	 (setq blk_col (vla-get-blocks odbx))
    	 (if (not (vl-catch-all-error-p
    		    (vl-catch-all-apply
    		      (function (lambda () (vla-item blk_col bname)))
    		    )
    		  )
    	     )
    	   (progn
    	     (setq cert_blk (vla-item blk_col bname))
    	     (not
    	       (vl-catch-all-error-p
    		 (vl-catch-all-apply
    		   (function
    		     (lambda ()
    		       (vla-copyobjects
    			 odbx
    			 (vlax-safearray-fill
    			   (vlax-make-safearray vlax-vbobject '(0 . 0))
    			   (list (vla-item
    				   (vla-get-blocks odbx)
    				   bname
    				 )
    			   )
    			 )
    			 (vla-get-blocks adoc)
    		       )
    		     )
    		   )
    		 )
    	       )
    	     )
    	   )
    	 )
           )
           (princ "\File Not Found")
        )
      )
      (vlax-release-object odbx)
      (setq odbx nil)
      (mapcar (function (lambda (x)
    		      (vl-catch-all-apply
    			(function (lambda ()
    				    (vlax-release-object x)
    				  )
    			)
    		      )
    		    )
    	  )
    	  (list cert_blk blk_col)
      )
      (vla-setvariable adoc "SDI" mdmod)
      (vla-endundomark adoc)
      (gc)
      (princ)
    )
    
    (prompt "\ntype BFD to execute ...")
    (princ)

  9. #9
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,707
    Login to Give a bone
    0

    Default Re: searching a source DWG.

    Quote Originally Posted by fixo
    . . . this one as an example for more understanding about ObjectDBX . . .
    Thank you fixo, I am trying to understand and modifie the routine, but I fail.
    I am trying to find a text string type "ABC123" in all drawings in the pointed directory
    and if T print the filename. Is that possible ?

    : ) Happy Computing !

    kennet

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

    Default Re: searching a source DWG.

    Quote Originally Posted by kennet.sjoberg
    Thank you fixo, I am trying to understand and modifie the routine, but I fail.
    I am trying to find a text string type "ABC123" in all drawings in the pointed directory
    and if T print the filename. Is that possible ?

    : ) Happy Computing !

    kennet
    Yes. Open the draiwng with ObjectDBX, and then search each layout for any text/mtext object, and then check the value. If you need more help, just post back and someone will help.

Page 1 of 6 12345 ... LastLast

Similar Threads

  1. Searching the Help
    By jpaulsen in forum AutoCAD Civil 3D - General
    Replies: 9
    Last Post: 2011-12-07, 03:20 PM
  2. Searching for labels.
    By tom.starkweather in forum AutoCAD Civil 3D - General
    Replies: 2
    Last Post: 2004-11-24, 08:15 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
  •