| Author |
Message |
montyzoomer
Guest
|
Posted:
Sun Jan 09, 2005 8:51 pm Post subject:
Update Border Information |
|
|
I really need the help of this group. I need to be able to change the part number of over 600 drawings so I am looking for some clues on how to open a drawing and change the text by doing a look up in an XLS file. The XLS side I can handle but I do not know how to open a drawing in VBA or change an entry in the drawing border.
I hope someone can help me out, it will be most appreciated.
Thanks
Monty
|
|
| Back to top |
|
 |
Walt Engle
Guest
|
Posted:
Sun Jan 09, 2005 10:09 pm Post subject:
Re: Update Border Information |
|
|
| Why not use a lsp routine that looks for certain key words and replaces them? I have one, if you're interested. |
|
| Back to top |
|
 |
montyzoomer
Guest
|
Posted:
Mon Jan 10, 2005 12:51 am Post subject:
Re: Update Border Information |
|
|
I would appreciate a copy, can you call lsp routine in VBA
Thanks
Monty
|
|
| Back to top |
|
 |
Walt Engle
Guest
|
Posted:
Mon Jan 10, 2005 1:16 am Post subject:
Re: Update Border Information |
|
|
Here it is:
; CHGTEXT.LSP
; CHANGES TEXT GLOBALLY
; This program will replace every occurrence of an "old string" with a
; "new string".
(defun chgterr (s)
(if (/= s "Function cancelled")
(princ (strcat "\nError: " s))
)
(setq p nil)
(setq *error* olderr)
(princ)
)
(defun C:CHGTEXT (/ p l n e os as ns st s nsl osl sl si chf chm olderr)
(setq olderr *error*
*error* chgterr
chm 0)
(setq p (ssget))
(if p (progn
(while (= 0 (setq osl (strlen (setq os (getstring t "\nOld string:
")))))
(princ "Null input invalid")
)
(setq nsl (strlen (setq ns (getstring t "\nNew string: "))))
(setq l 0 n (sslength p))
(while (< l n)
(if (= "TEXT"
(cdr (assoc 0 (setq e (entget (ssname p l))))))
(progn
(setq chf nil si 1)
(setq s (cdr (setq as (assoc 1 e))))
(while (= osl (setq sl (strlen
(setq st (substr s si osl)))))
(if (= st os)
(progn
(setq s (strcat (substr s 1 (1- si)) ns
(substr s (+ si osl))))
(setq chf t)
(setq si (+ si nsl))
)
(setq si (1+ si))
)
)
(if chf (progn
(setq e (subst (cons 1 s) as e))
(entmod e)
(setq chm (1+ chm))
))
)
)
(setq l (1+ l))
)
))
(princ "Changed ")
(princ chm)
(princ " text lines.")
(terpri)
(setq *error* olderr)
(princ)
) |
|
| Back to top |
|
 |
Laurie Comerford
Guest
|
Posted:
Mon Jan 10, 2005 1:31 am Post subject:
Re: Update Border Information |
|
|
Hi Monty,
You can call lisp from VBA with the SendCommand. However in pre-R2005
AutoCAD, you can not reliably return to VBA due to the VBA not knowing when
the Lisp function is complete. I believe this has been fixed in R2005.
You would be better off doing the whole exercise in VBA. The search and
replace bits of your code will only be a few lines.
--
Laurie Comerford
CADApps
www.cadapps.com.au
"montyzoomer" <nospam@address.withheld> wrote in message
news:4342066.1105300343710.JavaMail.jive@jiveforum2.autodesk.com...
| Quote: | I would appreciate a copy, can you call lsp routine in VBA
Thanks
Monty |
|
|
| Back to top |
|
 |
montyzoomer
Guest
|
Posted:
Mon Jan 10, 2005 1:08 pm Post subject:
Re: Update Border Information |
|
|
Laurie
Thanks for the information, I would prefer to complete the task in VBA but I only have real experience with normal office applications. What I need to understand is the code method for opening a drawing and then how to search for a string and change it.
If you can guide me on this I would appreciate it.
Regards
Monty |
|
| Back to top |
|
 |
GaryDF
Guest
|
Posted:
Mon Jan 10, 2005 8:10 pm Post subject:
Re: Update Border Information |
|
|
You can use objectdbx to open and change the drawings. Let me know if
this will work for you, and I can post the code.
Gary
"montyzoomer" <nospam@address.withheld> wrote in message
news:10278104.1105285900539.JavaMail.jive@jiveforum1.autodesk.com...
| Quote: | I really need the help of this group. I need to be able to change the part
number of over 600 drawings so I am looking for some clues on how to open a |
drawing and change the text by doing a look up in an XLS file. The XLS side I can
handle but I do not know how to open a drawing in VBA or change an entry in the
drawing border.
| Quote: |
I hope someone can help me out, it will be most appreciated.
Thanks
Monty |
|
|
| Back to top |
|
 |
montyzoomer
Guest
|
Posted:
Mon Jan 10, 2005 8:48 pm Post subject:
Re: Update Border Information |
|
|
Gary,
I am open to give it a go, would it be possible to E mail the code. My address is
ian@bie.co.uk
Thanks for your help
Regards
Ian |
|
| Back to top |
|
 |
GaryDF
Guest
|
Posted:
Mon Jan 10, 2005 9:06 pm Post subject:
Re: Update Border Information |
|
|
Sent routine.
Gary
"montyzoomer" <nospam@address.withheld> wrote in message
news:29414680.1105372149209.JavaMail.jive@jiveforum1.autodesk.com...
| Quote: | Gary,
I am open to give it a go, would it be possible to E mail the code. My address
is
ian@bie.co.uk
Thanks for your help
Regards
Ian |
|
|
| Back to top |
|
 |
|
|
|
|