<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Replace subroutine from directory folder in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/replace-subroutine-from-directory-folder/m-p/5968782#M135566</link>
    <description>so it would replace blocks on the draw, individual references and not globally from a list of blocks that i have already created that are stored on my computer</description>
    <pubDate>Wed, 30 Dec 2015 20:00:09 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2015-12-30T20:00:09Z</dc:date>
    <item>
      <title>Replace subroutine from directory folder</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/replace-subroutine-from-directory-folder/m-p/5968413#M135561</link>
      <description>&lt;P&gt;Ok so i have been using this routine bre.lsp and it has been amazing but i dont know how to write a routine for autocad 2004 so i wanted to know the best way to write a routine to replace objects on a draw from a folder or directory search. if this already exist that would be great, if not please let me know..thanks&lt;/P&gt;</description>
      <pubDate>Wed, 30 Dec 2015 16:46:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/replace-subroutine-from-directory-folder/m-p/5968413#M135561</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-12-30T16:46:19Z</dc:date>
    </item>
    <item>
      <title>Re: Replace subroutine from directory folder</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/replace-subroutine-from-directory-folder/m-p/5968485#M135562</link>
      <description>&lt;P&gt;The Cadalyst CAD Tips site has several things related to replacing Blocks [if that's what you're talking about -- it's not quite clear to me], some of which may do what you're after -- try a &lt;A href="http://cadtips.cadalyst.com/node/tiplisting?keywords=block%20replace&amp;amp;destination=node%2Ftiplisting" target="_self"&gt;Search there&lt;/A&gt;. &amp;nbsp;Otherwise, can you post the routine, or a link to where it can be downloaded, so we can see exactly what it does, and a more detailed description of what you want it to do differently?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Dec 2015 17:35:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/replace-subroutine-from-directory-folder/m-p/5968485#M135562</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2015-12-30T17:35:16Z</dc:date>
    </item>
    <item>
      <title>Re: Replace subroutine from directory folder</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/replace-subroutine-from-directory-folder/m-p/5968609#M135563</link>
      <description>is there a way that you know of where i can make a simple function to&lt;BR /&gt;replace any object in a drawing with any object in a folder...lets say i&lt;BR /&gt;want to select an item, type replace, then select the item from a list of&lt;BR /&gt;items on screen to replace it with</description>
      <pubDate>Wed, 30 Dec 2015 18:44:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/replace-subroutine-from-directory-folder/m-p/5968609#M135563</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-12-30T18:44:37Z</dc:date>
    </item>
    <item>
      <title>Re: Replace subroutine from directory folder</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/replace-subroutine-from-directory-folder/m-p/5968733#M135564</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;is there a way that you know of where i can make a simple function to&amp;nbsp;replace any object in a drawing with any object in a folder...&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What kind(s) of object(s)? &amp;nbsp;If you're talking about Blocks, it shouldn't be too hard, and some of the routines in the Search in my previous Reply may be close to what you want. &amp;nbsp;But if you want to replace, for example, a Circle with an Ellipse, the Ellipse can't be "in a folder" except as the content of a &lt;EM&gt;drawing&lt;/EM&gt; file, so it would need to come in by way of something like Inserting it as a Block [though it can be Exploded in the process, so it doesn't &lt;EM&gt;remain&lt;/EM&gt; a Block]. &amp;nbsp;And if you &lt;EM&gt;are&lt;/EM&gt; talking only about Blocks, when you say "replace," do you mean you want to replace individual Block references with different ones, or you want to replace the Block &lt;EM&gt;definition&lt;/EM&gt; so that &lt;EM&gt;all&lt;/EM&gt; such Blocks in the drawing are replaced? &amp;nbsp;The more detail you can provide about exactly what you want to do, including the range of possible object types, how you would want the &lt;EM&gt;location&lt;/EM&gt; of the replacement object to determined, etc., the better.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Dec 2015 19:39:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/replace-subroutine-from-directory-folder/m-p/5968733#M135564</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2015-12-30T19:39:09Z</dc:date>
    </item>
    <item>
      <title>Re: Replace subroutine from directory folder</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/replace-subroutine-from-directory-folder/m-p/5968776#M135565</link>
      <description>the subroutine that allows me to select a block on the draw as a source and then replace all following selected blocks with the source that has been selected. now i have a directory of shapes and items setup as blocks but bre.lsp wont work with those because they are not already on the draw. what i want to do is create a button or command that can be pressed or typed after a block is selected and replace it (scale, size and direction) with any one of the items from a drop down list. below is the text of the routine that i have loaded into autocad so basically if i could figure out a way to either create a button that would do this or re write the routine below to allow item selection to be from a list of created items instead of just whats on the drawing then it would be perfect similar to the command "blockreplace" but instead of typing in a search bar what i want, all the items that i have are presented in a list . (defun c:BRE (/ *error* blk f ss temp) ;; Replace multiple instances of selected blocks (can be different) with selected block ;; Size and Rotation will be taken from original block and original will be deleted ;; Required subroutines: AT:GetSel ;; Alan J. Thompson, 02.09.10 ;; Found at: &lt;A href="http://www.cadtutor.net/forum/showthread.php?48458-Replace-Selected-Block-Or-Blocks-With-Another-Block" target="_blank"&gt;http://www.cadtutor.net/forum/showthread.php?48458-Replace-Selected-Block-Or-Blocks-With-Another-Block&lt;/A&gt; (vl-load-com) (defun *error* (msg) (and f *AcadDoc* (vla-endundomark *AcadDoc*)) (if (and msg (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*QUIT*,"))) (princ (strcat "\nError: " msg)) ) ) (if (and (AT:GetSel entsel "\nSelect replacement block: " (lambda (x / e) (if (and (eq "INSERT" (cdr (assoc 0 (setq e (entget (car x)))))) (/= 4 (logand (cdr (assoc 70 (tblsearch "BLOCK" (cdr (assoc 2 e))))) 4)) (/= 4 (logand (cdr (assoc 70 (entget (tblobjname "LAYER" (cdr (assoc 8 e)))))) 4)) ) (setq blk (vlax-ename-&amp;gt;vla-object (car x))) ) ) ) (princ "\nSelect blocks to be repalced: ") (setq ss (ssget "_:L" '((0 . "INSERT")))) ) (progn (setq f (not (vla-startundomark (cond (*AcadDoc*) ((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object)))) ) ) ) ) (vlax-for x (setq ss (vla-get-activeselectionset *AcadDoc*)) (setq temp (vla-copy blk)) (mapcar (function (lambda (p) (vl-catch-all-apply (function vlax-put-property) (list temp p (vlax-get-property x p)) ) ) ) '(Insertionpoint Rotation xScaleFactor YScaleFactor ZScaleFactor ) ) (vla-delete x) ) (vla-delete ss) (*error* nil) ) ) (princ) ) (defun AT:GetSel (meth msg fnc / ent good) ;; meth - selection method (entsel, nentsel, nentselp) ;; msg - message to display (nil for default) ;; fnc - optional function to apply to selected object ;; Ex: (AT:GetSel entsel "\nSelect arc: " (lambda (x) (eq (cdr (assoc 0 (entget (car x)))) "ARC"))) ;; Alan J. Thompson, 05.25.10 (setvar 'errno 0) (while (not good) (setq ent (meth (cond (msg) ("\nSelect object: ") ) ) ) (cond ((vl-consp ent) (setq good (cond ((or (not fnc) (fnc ent)) ent) ((prompt "\nInvalid object!")) ) ) ) ((eq (type ent) 'STR) (setq good ent)) ((setq good (eq 52 (getvar 'errno))) nil) ((eq 7 (getvar 'errno)) (setq good (prompt "\nMissed, try again."))) ) ) ) …</description>
      <pubDate>Wed, 30 Dec 2015 19:56:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/replace-subroutine-from-directory-folder/m-p/5968776#M135565</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-12-30T19:56:52Z</dc:date>
    </item>
    <item>
      <title>Re: Replace subroutine from directory folder</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/replace-subroutine-from-directory-folder/m-p/5968782#M135566</link>
      <description>so it would replace blocks on the draw, individual references and not globally from a list of blocks that i have already created that are stored on my computer</description>
      <pubDate>Wed, 30 Dec 2015 20:00:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/replace-subroutine-from-directory-folder/m-p/5968782#M135566</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-12-30T20:00:09Z</dc:date>
    </item>
    <item>
      <title>Re: Replace subroutine from directory folder</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/replace-subroutine-from-directory-folder/m-p/5969460#M135567</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;so it would replace blocks on the draw, individual references and not globally from a list of blocks that i have already created that are stored on my computer&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Here's a start, using &lt;EM&gt;two&lt;/EM&gt;&amp;nbsp;routines just for now. &amp;nbsp;If they work together for you, they can be &lt;EM&gt;combined&lt;/EM&gt; into one routine.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your Blocks are all&amp;nbsp;&lt;EM&gt;&lt;FONT color="#3366FF"&gt;drawing files in a single folder&lt;/FONT&gt;&lt;/EM&gt;, the following will call up a File Dialog Box which &lt;EM&gt;will be the list&lt;/EM&gt; from which to select one of them:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(vl-load-com)&lt;FONT color="#999999"&gt;; in case needed&lt;/FONT&gt;&lt;BR /&gt;(defun C:&lt;STRONG&gt;GBFD&lt;/STRONG&gt; (/ fname dname)&lt;FONT color="#FF00FF"&gt;; = Get Block from File Dialog-box&lt;/FONT&gt;
  (command
    "_.INSERT"
    (setq fname &lt;FONT color="#FF00FF"&gt;; = File name -- will bring in as Block definition&lt;/FONT&gt;
      (getfiled "Select drawing:" "&lt;STRONG&gt;&lt;EM&gt;&lt;FONT color="#3366FF"&gt;X:/Your/Folder/Location/&lt;/FONT&gt;&lt;/EM&gt;&lt;/STRONG&gt;" "dwg" 0)&lt;FONT color="#FF00FF"&gt;;&lt;/FONT&gt;&lt;EM&gt;&lt;FONT color="#3366FF"&gt;&amp;lt;--&lt;STRONG&gt;EDIT&lt;/STRONG&gt; drive &amp;amp; file path&lt;/FONT&gt;&lt;/EM&gt;
    )&lt;FONT color="#999999"&gt;; setq&lt;/FONT&gt;
  )&lt;FONT color="#999999"&gt;; command&lt;/FONT&gt;
  (command)&lt;FONT color="#FF00FF"&gt;; cancel without actually Inserting one&lt;/FONT&gt;
  (setq
    dname (substr fname (+ (vl-string-position 92 fname 1 T) 2))&lt;FONT color="#FF00FF"&gt;; = Drawing name&lt;/FONT&gt;
    bname (substr dname 1 (- (strlen dname) 4))&lt;FONT color="#FF00FF"&gt;; = Block name [dname with ".dwg" removed]&lt;/FONT&gt;
  )&lt;FONT color="#999999"&gt;; setq&lt;/FONT&gt;
  (setvar 'insname bname)&lt;FONT color="#FF00FF"&gt;; set as default for Insert command&lt;/FONT&gt;
)&lt;FONT color="#999999"&gt;; defun&lt;/FONT&gt;
(prompt "\nType GBFD to Get a Block from a File Dialog-box in &lt;STRONG&gt;&lt;EM&gt;&lt;FONT color="#3366FF"&gt;YourFolder&lt;/FONT&gt;&lt;/EM&gt;&lt;/STRONG&gt;.")&lt;FONT color="#FF00FF"&gt;;&lt;/FONT&gt;&lt;EM&gt;&lt;FONT color="#3366FF"&gt;&amp;lt;--&lt;STRONG&gt;EDIT&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/EM&gt;&lt;/PRE&gt;
&lt;P&gt;Run&amp;nbsp;the &lt;STRONG&gt;GBFD&lt;/STRONG&gt; command defined by that. &amp;nbsp;It will import the selected drawing into the current drawing as a Block definition [but &lt;EM&gt;not&lt;/EM&gt; actually Insert one], and will both store that Block name in the 'bname' variable &lt;EM&gt;and&lt;/EM&gt;&amp;nbsp;make it the current default Block name for the Insert command.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Then&lt;/EM&gt;, run the &lt;STRONG&gt;BRS&lt;/STRONG&gt;&amp;nbsp;[= &lt;STRONG&gt;B&lt;/STRONG&gt;lock &lt;STRONG&gt;R&lt;/STRONG&gt;eplace by &lt;STRONG&gt;S&lt;/STRONG&gt;election] command from &lt;STRONG&gt;BlockReplace.lsp&lt;/STRONG&gt;, available &lt;A href="https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/find-and-replace-group-of-blocks-that-are-selected/m-p/4333482#M313227" target="_self"&gt;here&lt;/A&gt;. &amp;nbsp;The first time you run it, it will &lt;EM&gt;offer Insert's default Block name&lt;/EM&gt; [the one you just picked from the File Dialog Box] -- accept that default, and select as many existing Blocks [of any name] as you want, and they will all be turned into that Block, keeping their Layers, Scale factors, Rotation angles, etc. &amp;nbsp;Thereafter, &lt;STRONG&gt;BRS&lt;/STRONG&gt;&amp;nbsp;will offer the Block name last used within itself, so if you bring in another using &lt;STRONG&gt;GBFD&lt;/STRONG&gt;, you will [for now] need to type its name when the &lt;STRONG&gt;BRS&lt;/STRONG&gt; command asks for a Block name. &amp;nbsp;That can be made automatic in a &lt;EM&gt;combination&lt;/EM&gt; routine if this pair of routines works for you otherwise.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Dec 2015 17:07:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/replace-subroutine-from-directory-folder/m-p/5969460#M135567</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2015-12-31T17:07:07Z</dc:date>
    </item>
  </channel>
</rss>

