| Author |
Message |
mnash
Guest
|
Posted:
Mon Jan 10, 2005 9:57 pm Post subject:
Activating a Specific UCS |
|
|
In any given drawing there is a UCS with a specific name to the UCS, in every drawing the name always consists of two parts, the first being the "filename in its entirety", followed by "-C".
Example
Drawing with filename "Section" will have a UCS in the drawing called "Section-C".
Drawing with filename "Detail" will have a UCS in the drawing called "Detail-C".
Is there a way where in all drawings we can activate the "filename+-C" UCS in all drawings?
Thanks and cheers
MN
|
|
| Back to top |
|
 |
Matt W
Guest
|
Posted:
Mon Jan 10, 2005 10:19 pm Post subject:
Re: Activating a Specific UCS |
|
|
Try this...
| Code: |
; FROM ACADX.COM
;;;==================================================================
;;; (JustStem cFileName)
;;; Returns the stem name (the file name before the extension)
;;; from a complete path and file name.
;;;------------------------------------------------------------------
;;; Parameters:
;;; cFileName str to check
;;;------------------------------------------------------------------
;;; Returns:
;;; [STR]
;;; Example: (setq a "C:\\MyFolder\\MyFile.txt")
;;; (JustStem a) ; returns "MyFile"
;;;------------------------------------------------------------------
(defun JustStem (cFileName / fName DotLoc)
(setq fName (justFName cFileName))
(setq DotLoc (rat "." fName))
(if (> DotLoc 0)
(substr fName 1 (1- DotLoc))
fName
) ;_ end of if
) ;_ end of defun
; ALSO FROM ACADX.COM
;;;===========================================================================
;;; (Rat cSearchExpression cExpressionSearched)
;;; Returns the numeric position of the last (rightmost)
;;; occurrence of a character string within another character string.
;;;---------------------------------------------------------------------------
;;; Parameters:
;;; cSearchExpression [STR] - String to search for
;;; cExpressionSearched [STR] - String to search
;;;---------------------------------------------------------------------------
;;; Returns:
;;; [INT] - Posistion of the string
;;; Example: (setq a "A Lot of Text.")
;;; (Rat "Text" a) ; returns 10
;;;===========================================================================
(defun Rat (cSearch cSearchIn / return SearchFor cont n)
;; We need to escape for special characters
(cond
(
(= cSearch "\\")
(setq SearchFor "*`\\*")
)
(
(= cSearch ".")
(setq SearchFor "*`.*")
)
(
(= cSearch "#")
(setq SearchFor "*`#*")
)
(
(= cSearch "*")
(setq SearchFor "*`**")
)
(
(= cSearch "~")
(setq SearchFor "*`~*")
)
(
(= cSearch "-")
(setq SearchFor "*`-*")
)
(
(= cSearch ",")
(setq SearchFor "*`,*")
)
(
(= cSearch "`")
(setq SearchFor "*``*")
)
(
T
(setq SearchFor (strcat "*" cSearch "*"))
)
) ;_ end of cond
(cond
(
;; Make sure there is a match
(not (wcmatch cSearchIn SearchFor))
(setq return 0)
)
(
T
(setq n (strlen cSearchIn))
(setq TestStr (substr cSearchIn n))
(setq cont T)
(while Cont
(if (wcmatch TestStr SearchFor)
(progn
(setq Cont nil)
(setq return n)
) ;_ end of progn
(progn
(setq n (1- n))
(setq TestStr (substr cSearchIn n))
) ;_ end of progn
) ;_ end of if
) ;_ end of while
)
) ;_ end of cond
return
) ;_ end of defun
(DEFUN C:UCS-TEST ( / )
(COMMAND "UCS" "R" (STRCAT (JUSTSTEM (GETVAR "DWGNAME")) "-C"))
)
(PRINC)
|
--
I support two teams: The Red Sox and whoever beats the Yankees.
"mnash" <nospam@address.withheld> wrote in message
news:6986990.1105376258177.JavaMail.jive@jiveforum1.autodesk.com...
| Quote: | In any given drawing there is a UCS with a specific name to the UCS, in
every drawing the name always consists of two parts, the first being the
"filename in its entirety", followed by "-C".
Example
Drawing with filename "Section" will have a UCS in the drawing called
"Section-C".
Drawing with filename "Detail" will have a UCS in the drawing called
"Detail-C".
Is there a way where in all drawings we can activate the "filename+-C" UCS
in all drawings?
Thanks and cheers
MN |
|
|
| Back to top |
|
 |
mnash
Guest
|
Posted:
Tue Jan 11, 2005 2:56 am Post subject:
Re: Activating a Specific UCS |
|
|
Thanks Red Sock, but it don'e seem to work I'm getting a malformed error on input, and i[m way in over my head with this program. I thought it would be much simpler than this, guess I'm wrong
|
|
| Back to top |
|
 |
ECCAD
Guest
|
Posted:
Tue Jan 11, 2005 3:06 am Post subject:
Re: Activating a Specific UCS |
|
|
Matt,
You may have to attach a .zip with the code. When I cut/paste
from Internet Explorer to Notepad / Wordpad, code that is in
a 'box' like yours, I get (1) long sentence, no Cr/Lf - I have to
go into the string and supply these manually in order to get
the code readable..Just a thought.
Bob |
|
| Back to top |
|
 |
T.Willey
Guest
|
Posted:
Tue Jan 11, 2005 3:22 am Post subject:
Re: Activating a Specific UCS |
|
|
To get the drawing name use
(setq FileName (getvar "dwgname"))
Then to get the base file name (with the extension) use
(setq DwgName (vl-filename-base FileName))
Then to get the UCS name use
(setq UCSName (strcat DwgName "-C"))
Then to restore the name use
(command "_.ucs" "_r" UCSName)
Hope that helps.
Tim |
|
| Back to top |
|
 |
mnash
Guest
|
Posted:
Tue Jan 11, 2005 4:12 pm Post subject:
Re: Activating a Specific UCS |
|
|
Thanks so much guys, but the ".dwg" is still being used in the filename, is it possible to filter out the ".dwg" for the UCS name?
Happy New Year all |
|
| Back to top |
|
 |
Matt W
Guest
|
Posted:
Tue Jan 11, 2005 6:28 pm Post subject:
Re: Activating a Specific UCS |
|
|
Huh.... never knew that was an issue. I always use OE and it's never been a
problem for me.
I'll keep that in mind.
Thanks for the info.
--
I support two teams: The Red Sox and whoever beats the Yankees.
"ECCAD" <nospam@address.withheld> wrote in message
news:24832661.1105394796455.JavaMail.jive@jiveforum1.autodesk.com...
| Quote: | Matt,
You may have to attach a .zip with the code. When I cut/paste
from Internet Explorer to Notepad / Wordpad, code that is in
a 'box' like yours, I get (1) long sentence, no Cr/Lf - I have to
go into the string and supply these manually in order to get
the code readable..Just a thought.
Bob |
|
|
| Back to top |
|
 |
T.Willey
Guest
|
Posted:
Tue Jan 11, 2005 8:56 pm Post subject:
Re: Activating a Specific UCS |
|
|
(setq DwgName (vl-filename-base FileName))
This should give you the base name for whatever FileName is.
If FileName = "section.dwg", it should return just "section", but if that isn't working, then you could do something like
(setq DwgName (substr 1 (- (strlen FileName) 4)))
This will return everything but the last four items in the string.
Hope that helped.
Tim |
|
| Back to top |
|
 |
mnash
Guest
|
Posted:
Tue Jan 11, 2005 9:14 pm Post subject:
Re: Activating a Specific UCS |
|
|
| Tim both worked, I hav e afile with a bunch of small lisps and after eliminating all of the above lisp, I still got the malformed list error, so now I have to trouble shoot the rest of the lisp file, but thanks for the valuable knowledge. |
|
| Back to top |
|
 |
T.Willey
Guest
|
Posted:
Tue Jan 11, 2005 9:26 pm Post subject:
Re: Activating a Specific UCS |
|
|
Happy to help.
Hope you get your file in order.
Tim |
|
| Back to top |
|
 |
|
|
|
|