Morning all,
I have a REV tag block that is insertable through the palettes (from the file "S:\Block Library\JST\tags.dwg" but I would like to create a lisp to insert it thorugh a quick short cut as well.
I've work on this for a couple hours now trying all sorts of methods and this is what I've come up with:
(defun c:rt (/ p blk sc) (setq p (getpoint "\n Select insertion point... :")) (setq sc (getvar 'dimscale)) (command "insert" "jst revision mark.dwg" P SC "" "") (princ) )
This work very well as long as the block definition is in the current drawing, if not the following is returned:
..."jst revision mark.dwg": Can't find file in search path:...
I do have "S:\Block Library\JST" in my support paths...
As A work around I also tried creating a dwg tiled "jst revision mark.dwg" and placing that the S drive folder, but when I do I recieve the following error:
...S:\Block
Library\JST\jst revision mark.dwg Block jst revision mark references itself
*Invalid*...
Can somone please explain how it's referencing it's self?
But more importantly, how to do I have the routine look to "S:\Block Library\JST\tags.dwg" for the definition and then insert that?
Thanks,
Chris
Solved! Go to Solution.
Solved by hmsilva. Go to Solution.
@cchiles wrote:
....
how to do I have the routine look to "S:\Block Library\JST\tags.dwg" for the definition and then insert that?
....
If you want the Block name in the drawing to be different from the drawing name it comes from:
(command "insert" "jst revision mark=tags" P SC "" "")
I am assuming there will be no tags.dwg in any location higher up in the Support File Search Path list than the one you want.
That may have a problem if you run it again, with such a Block name already defined, because it will want to know whether you want to redefine it. Any reason not to just use "tags" as the Block name in the drawing? If you do that, you can just do:
(command "insert" "tags" P SC "" "")
and if it's already in the drawing, it will use that definition, but if it's not, it will go looking for it in the Support File Search Paths under that as a drawing name.
The .dwg filetype ending is not necessary in any of this -- that's the only kind of file it will look for.
If I understood correctly, perhaps something like this
(defun c:rt (/ p blk sc) ;; test for a valid point (if (and (setq p (getpoint "\n Select insertion point... :")) (setq sc (getvar 'dimscale)) ) ;; search if the block definition exist (if (tblsearch "block" "jst revision mark") ;; if true inserts the block (command "insert" "jst revision mark" P SC "" "") ;; if not true test if find the main dwg (if (findfile "S:\\Block Library\\JST\\tags.dwg") (progn ;; if true inserts the main dwg (command "insert" "S:\\Block Library\\JST\\tags" p) ;; cancel the insertion, but the definition remains... (command) ;; inserts the block (command "insert" "jst revision mark" P SC "" "") ) ) ) ) (princ) )
Without importing all settings from the main dwg, you can take a look at Lee Mac's Import Block and use is routine to import just the block definition.
HTH
Henrique
@cchiles wrote:
....
As A work around I also tried creating a dwg tiled "jst revision mark.dwg" and placing that the S drive folder, but when I do I recieve the following error:
...S:\Block
Library\JST\jst revision mark.dwg Block jst revision mark references itself
*Invalid*...Can somone please explain how it's referencing it's self?
....
Some clarification needed, from the above and from hmsilva's suggestion: Some other things in what you've described make it sound like [my assumption in my previous Reply] the "tags.dwg" file is the definition of what you want to use as the "jst revision mark" Block. But from these other considerations, now I'm wondering whether "jst revision mark" is one Block definition [presumably among others] inside the "tags.dwg" file. If the latter is the case, then what I suggested before won't work, and I think it explains the references-itself problem, if your "jst revision mark.dwg" is a copy of "tags.dwg". If that's what's happening, I think hmsilva's suggestion may be the way to go if you want a routine defined, but you can also do it without any code, using the Design Center [ADC command] to pull a Block definition from another drawing.
@cchiles wrote:
Hey thanks Henrique - that works great!
One questions - at the end of the routine it returns:
"RT Unknown command "RT". Press F1 for help."
Why is that?
Sounds like too many Enters in the Insert command. Is the Block defined to always be uniformly scaled?
Here's my code as it stands:
;;;Insert Revision Mark ;;;Checks for RevCloud Layer A-Rev (Sets it current) & Create it if it's not there. ;;;Inserts "JST Revision Mark" from S:\Block Library\JST\Tags.dwg & Scales to current Dimscale (defun c:rt (/ cl p sc) ;;;Gets Current Layer (setq CL (getvar "clayer")) ;;;Searches for Layer "A-REV" (if (tblsearch "layer" "A-REV") (setvar "clayer" "A-REV") (command "_.-layer" "_make" "A-REV" "_color" "5" "" "") ) ;;;End of Search ;; test for a valid point (if (and (setq p (getpoint "\n Select insertion point... :")) (setq sc (getvar 'dimscale)) ) ;; search if the block definition exist (if (tblsearch "block" "jst revision mark") ;; if true inserts the block (command "insert" "jst revision mark" P SC "" "") ;; if not true test if find the main dwg (if (findfile "S:\\Block Library\\JST\\tags.dwg") (progn ;; if true inserts the main dwg (command "insert" "S:\\Block Library\\JST\\tags" p) ;; cancel the insertion, but the definition remains... (command) ;; inserts the block (command "insert" "jst revision mark" P SC "" "") ) ) ) ) ;;;Reset Current Layer (setvar "clayer" CL) (princ) )
I added a look up for layer "A-rev", if not there then create it. Then reset to previous layer.
Thanks Y'all.
Chris
@cchiles wrote:
Hey thanks Henrique - that works great!
One questions - at the end of the routine it returns:
"RT Unknown command "RT". Press F1 for help."
Why is that?
You're welcome, cchiles.
Glad I could help!
As Kent1Cooper already pointed out, the "RT Unknown command "RT". Press F1 for help." should result from an extra enter at the insert command, to prevent it change the
(command "insert" "jst revision mark" P SC "" "")
to
(command "insert" "jst revision mark" "_S" SC "_R" 0 P)
HTH
Henrique
Can't find what you're looking for? Ask the community or share your knowledge.