Author Topic: Changing path due to Rename files and folders.  (Read 1722 times)

0 Members and 1 Guest are viewing this topic.

HasanCAD

  • Swamp Rat
  • Posts: 1422
Changing path due to Rename files and folders.
« on: December 10, 2017, 03:10:06 AM »
Hi all
While working on a project comes instructions from the Clint to change buildings numbering (12 buildings ).
that impact on the file path in all files.
Is there a solution

Example:
CHange
V:\01.Projects\K-1502\DWG\01-AR BASE\0.1.9-BUILDINGS_09\K1502_B09_B_ALL.dwg
To
V:\01.Projects\K-1502\DWG\01-AR BASE\0.1.7-BUILDINGS_07\K1502_B07_B_ALL.dwg

Thanks in advance


xdcad

  • Bull Frog
  • Posts: 488
Re: Changing path due to Rename files and folders.
« Reply #1 on: December 11, 2017, 10:34:31 AM »
use REGEXP

Code: [Select]
;; http://bbs.xdcad.net , XDRX API
(defun XD::String:RegExpR (pat str nstr key / keys x)
  (if (not *xxvbsexp)
    (setq *xxvbsexp (vlax-get-or-create-object "VBScript.RegExp"))
  )
  (vlax-put *xxvbsexp 'Pattern pat)
  (if (not key)
    (setq key "")
  )
  (setq key (strcase key))
  (setq keys '(("I" "IgnoreCase")
       ("G" "Global")
       ("M" "Multiline")
      )
  )
  (mapcar
    '(lambda (x)
       (if (wcmatch key (strcat "*" (car x) "*"))
(vlax-put *xxvbsexp (read (cadr x)) 0)
(vlax-put *xxvbsexp (read (cadr x)) -1)
       )
     )
    keys
  )
  (vlax-invoke *xxvbsexp 'replace str nstr)
)

(setq txt  "V:\\01.Projects\\K-1502\\DWG\\01-ARBASE\\0.1.9-BUILDINGS_09\\K1502_B09_B_ALL.dwg")
(setq txt1 (xd::string:regexpr "BUILDINGS_[0-9]+" txt "BUILDINGS_07" ""))
(setq txt2 (xd::string:regexpr "B[0-9]+" txt1 "B07" ""))
(setq txt3 (xd::string:regexpr "0.1.[0-9]+" txt2 "0.1.7" ""))

or:

1.(setq txt1 (xd::string:regexpr "(BUILDINGS_)[0-9]+" txt  (strcat "$1" "07") ""))
$1 = BUILDINGS_

2.(setq txt2 (xd::string:regexpr "(B)[0-9]+" txt1 (strcat "$1" "07") ""))
$1=B

3.(setq txt3 (xd::string:regexpr "(0.1.)[0-9]+" txt2 (strcat "$1" "7") ""))
$1=0.1.

or merge 1,2:
(setq txt1 (xd::string:regexpr "(BUILDINGS_)[0-9]+|(B)[0-9]+" txt (strcat "$1" "07") ""))
or
(setq txt1 (xd::string:regexpr "(B|BUILDINGS_)[0-9]+" txt (strcat "$1" "07") ""))

(setq txt3 (xd::string:regexpr "(0.1.)[0-9]+" txt1 (strcat "$1" "7") ""))

===================
txt3 = "V:\\01.Projects\\K-1502\\DWG\\01-ARBASE\\0.1.7-BUILDINGS_07\\K1502_B07_B_ALL.dwg"

functions:

Code: [Select]
(defun _AddBuildingFloor (str floor / txt1)
  (setq txt1 (xd::string:regexpr
       "(B|BUILDINGS_)[0-9]+"
       txt
       (strcat "$1" floor)
       ""
     )
  )
  (setq txt1 (xd::string:regexpr
       "(0.1.)[0-9]+"
       txt1
       (strcat "$1" (itoa (atoi floor)))
       ""
     )
  )
)

command: (_ADDBUILDINGFLOOR txt "07")
"V:\\01.Projects\\K-1502\\DWG\\01-ARBASE\\0.1.7-BUILDINGS_07\\K1502_B07_B_ALL.dwg"

command: (_ADDBUILDINGFLOOR txt "12")
"V:\\01.Projects\\K-1502\\DWG\\01-ARBASE\\0.1.12-BUILDINGS_12\\K1502_B12_B_ALL.dwg"
« Last Edit: December 11, 2017, 11:36:24 AM by xdcad »
The code I wrote uses XDRX-API,which can be downloaded from github.com and is updated at any time.
===================================
https://github.com/xdcad
https://sourceforge.net/projects/xdrx-api-zip/
http://bbs.xdcad.net

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: Changing path due to Rename files and folders.
« Reply #2 on: December 12, 2017, 01:54:52 AM »
Thanks xdcad

didier

  • Newt
  • Posts: 48
  • expatrié
Re: Changing path due to Rename files and folders.
« Reply #3 on: December 12, 2017, 10:49:09 AM »
Hello

why not use the express command: redir ?

amicalement
eternal beginner ...
my english is not fluent ...

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: Changing path due to Rename files and folders.
« Reply #4 on: December 12, 2017, 11:45:58 AM »
Hello

why not use the express command: redir ?

amicalement

REDIR modify the path but file should be opened.