Author Topic: Re-defining blocks  (Read 6120 times)

0 Members and 1 Guest are viewing this topic.

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Re-defining blocks
« on: July 26, 2006, 11:14:59 AM »
Not LISP related, persay, but a programming question nonetheless.

When inserting a block from a pulldown or button using a macro, is it possible to redefine a block already in the drawing with a newer version off the server?

Code: [Select]
[Continuous Ridge Vent - Front]^C^C^C-insert;"//D22/cadjobs/RA Faganel Builders/BLOCKS/Notes/Elevation-Continuous_Ridge_Vent-Front.dwg";\1;1;0;explode;last;
(and yes, I know you can explode the block during the insert with a * before the block name, but then you don't get a preview of the block while inserting :-P)

GDF

  • Water Moccasin
  • Posts: 2081
Re: Re-defining blocks
« Reply #1 on: July 26, 2006, 11:44:10 AM »
Maybe this...?

Code: [Select]

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;; Redefining a Block Function ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;|
Updating a Block Path: If you enter a block name without a path name, AutoCAD first
searches the current drawing data for an existing block definition by that name. If
no such block definition exists in the current drawing, AutoCAD searches the library
path for a file of the same name. If AutoCAD finds such a file, it uses the file name
for the block name upon insertion of the block definition. AutoCAD uses the same block
definition for subsequent insertions of that block. You can replace an existing block
definition with an external file by entering the following at the Enter Block Name
prompt: block name=file name


Updating a Block Definition: If you make changes to a block file that is inserted in your
drawing and you want to change the existing block definition without creating a new block
insertion, enter the following at the Specify Insertion Point prompt (following the Enter
Block Name prompt): block name=

If you enter = after the block name, AutoCAD displays the following prompt:

Block "current" already exists. Redefine it? [Yes/No] <No>: Enter y, enter n, or press ENTER

If you choose to redefine the block, AutoCAD replaces the existing block definition with the
new block definition. AutoCAD regenerates the drawing and the new definition is applied to
all existing insertions of it. Press ESC when AutoCAD prompts you for the insertion point
if you do not want AutoCAD to insert a new block into the drawing.
|;
(defun ARCH:BLKNAM  (blknam path / e)
  (setq e (tblobjname "BLOCK" blknam))
  (if e
    (command "insert" (strcat blknam "=" path blknam) ^c))
  (princ))

;;(ARCH:BLKNAM "SYMDR" (strcat ARCH#CUSF "SYMS/"))


Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

CADaver

  • Guest
Re: Re-defining blocks
« Reply #2 on: July 26, 2006, 11:56:20 AM »
Code: [Select]
[Continuous Ridge Vent - Front]^C^C^C-insert;"//D22/cadjobs/RA Faganel Builders/BLOCKS/Notes/Elevation-Continuous_Ridge_Vent-Front.dwg";\1;1;0;explode;last;
I would lispy the redefine sorta like this (I'm sure there's a hunert ways of doing it a lot slicker.)

Quote
[Continuous Ridge Vent - Front]^C^C^C(command "-insert" "Elevation-Continuous_Ridge_Vent-Front=//D22/cadjobs/RA Faganel Builders/BLOCKS/Notes/Elevation-Continuous_Ridge_Vent-Front.dwg"(command))-insert;Elevation-Continuous_Ridge_Vent-Front;s;1;r;0;\explode;last;

I'd probably make sure that directory was in my path.

BTW, if I caught someone around here naming a block "Elevation-Continuous_Ridge_Vent-Front", I'd drill holes in his kneecaps. "VENT-CR-E-F", we worked just fine for years with 8 characters.  Just because ya' can doesn't mean ya' should.   But then again, that's just me.
« Last Edit: July 26, 2006, 12:03:26 PM by CADaver »

Slim©

  • Needs a day job
  • Posts: 6566
  • The Dude Abides...
Re: Re-defining blocks
« Reply #3 on: July 26, 2006, 12:08:55 PM »

BTW, if I caught someone around here naming a block "Elevation-Continuous_Ridge_Vent-Front", I'd drill holes in his kneecaps. "VENT-CR-E-F", we worked just fine for years with 8 characters.  Just because ya' can doesn't mean ya' should.   But then again, that's just me.

AMEN!!!
I drink beer and I know things....

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Re: Re-defining blocks
« Reply #4 on: July 26, 2006, 12:19:50 PM »
Thanks everyone, I'll try it out at lunch.


BTW, if I caught someone around here naming a block "Elevation-Continuous_Ridge_Vent-Front", I'd drill holes in his kneecaps. "VENT-CR-E-F", we worked just fine for years with 8 characters.  Just because ya' can doesn't mean ya' should.   But then again, that's just me.

AMEN!!!

Actually, I'm the one that names them like that  :oops:
In my mind, why try to decifer a code of characters when I don't have to anymore?  I mainly have this view from when I look for a block that is in our blocks folder (created well before I came to work here).  Takes so much time to do this.  Was really bad when it was "RES1007.dwg" , "RES1008.dwg" , "COM1248.dwg" , etc.

CADaver

  • Guest
Re: Re-defining blocks
« Reply #5 on: July 26, 2006, 12:43:26 PM »
If you're gonna try the macro, watch out for typos, I didn't test it or anything prior to posting.  I was actually kinda hoping one of the whiz kids would offer something really slick.


Actually, I'm the one that names them like that  :oops:
where's my patented kneecap ventilator


In my mind, why try to decifer a code of characters when I don't have to anymore? 
Descriptive naming is important (see the word VENT in my sample), however, as you can see by the length of this simple macro code, that the volume of characters has made the coding much less friendly.  In coding, I've leaned that the more times I hit a key the more chances I have of screwing it up.


I mainly have this view from when I look for a block that is in our blocks folder (created well before I came to work here).  Takes so much time to do this.  Was really bad when it was "RES1007.dwg" , "RES1008.dwg" , "COM1248.dwg" , etc.
musta' been an architect.  I'm all for descriptive names, but you don't need to completely spell out ELEVATION or CONTINUOUS.

Using my sample of "VENT-CR-E-F",I prefix the name with what the name of the element, in this case VENT.  I know I'm looking for a vent, so this will help in sorting, it will also help if I later begin to extract data from the drawing, followed by a description CR=Cont.Ridge SOF=SOFFIT, TRB=Roof Turbin etc., followed by the kind of view E=Elev P=Plan and direction for elevations F=Front S=Side.  Nearly everything we do follows this or simliar conventions.

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: Re-defining blocks
« Reply #6 on: July 26, 2006, 01:13:10 PM »
I mainly have this view from when I look for a block that is in our blocks folder (created well before I came to work here).  Takes so much time to do this.  Was really bad when it was "RES1007.dwg" , "RES1008.dwg" , "COM1248.dwg" , etc.
musta' been an architect.
  Hey I Heard that.  I will run you thru my patented sharpener for crayons.  :-D  Okay the Architect's patented sharpener for crayons.  I have meaning to try it out.

I will offer my two cents, that comes from my previous life as a Manufacturing Engineer.  You have to be careful with using coded characters for part names (or blocks names as in this case)  we had 30 engineers that all had a different opinion on how a 1/4-20 hex head bolt should be coded in its description and thus we had 30 different part numbers for that bolt.  (actually we had 21 p/n's)  the way we clean it up was thru an access data base. The data base created the code with the information that the user in.  By having 1 p/n for a part, you get better pricing due to quantity pricing and it makes the bean counters job easier which in turn is suppose to give you a larger profit sharing bonus, supposedly.

This goes the same for block names.  "IF" everyone knows "YOUR" system of coding a block name, then you are all set.  However this present a major effort of communicating your code to your users.  It also leads to bad names because of user laziness or error.  Automation is the only way to go, IMHO.
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

CADaver

  • Guest
Re: Re-defining blocks
« Reply #7 on: July 26, 2006, 01:30:47 PM »
we had 30 engineers that all had a different opinion on how a 1/4-20 hex head bolt should be coded in its description and thus we had 30 different part numbers for that bolt.  (actually we had 21 p/n's)
...
This goes the same for block names.  "IF" everyone knows "YOUR" system of coding a block name, then you are all set.  However this present a major effort of communicating your code to your users.  It also leads to bad names because of user laziness or error. 
Therein lies the foundation for standardization, and the shorter the better.  One part, one part number, one block name, 30 guys DON'T get to choose.


Automation is the only way to go, IMHO.
Coded naming conventions make automating the process al the easier.

CADaver

  • Guest
Re: Re-defining blocks
« Reply #8 on: July 26, 2006, 01:34:58 PM »
Code: [Select]
    (command "insert" (strcat blknam "=" path blknam) ^c))

Hijacking the thread in a different direction for moment. 
It is my understanding that ^C is not lisp.  It works in this case because lisp can not interpret the code and kills the insertion process.  The better option would be:
Code: [Select]
    (command "insert" (strcat blknam "=" path blknam) (command)))

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Re-defining blocks
« Reply #9 on: July 26, 2006, 01:39:21 PM »
Code: [Select]
    (command "insert" (strcat blknam "=" path blknam) ^c))

Hijacking the thread in a different direction for moment. 
It is my understanding that ^C is not lisp.  It works in this case because lisp can not interpret the code and kills the insertion process.  The better option would be:
Code: [Select]
    (command "insert" (strcat blknam "=" path blknam) (command)))
You are correct.  If "^c" has not been asigned, then it is set to nil, which is what "command" in this instance gives you, in my understanding.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Re-defining blocks
« Reply #10 on: July 26, 2006, 02:22:56 PM »
Code: [Select]
    (command "insert" (strcat blknam "=" path blknam) ^c))

Hijacking the thread in a different direction for moment. 
It is my understanding that ^C is not lisp.  It works in this case because lisp can not interpret the code and kills the insertion process.  The better option would be:
Code: [Select]
    (command "insert" (strcat blknam "=" path blknam) (command)))
You are correct.  If "^c" has not been asigned, then it is set to nil, which is what "command" in this instance gives you, in my understanding.


I forgot about that, thanks for the heads up.

Gary

Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

CADaver

  • Guest
Re: Re-defining blocks
« Reply #11 on: July 26, 2006, 02:25:57 PM »
You are correct.  If "^c" has not been asigned, then it is set to nil, which is what "command" in this instance gives you, in my understanding.
yeah, what he said.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Re-defining blocks
« Reply #12 on: July 26, 2006, 02:33:36 PM »
You are correct.  If "^c" has not been asigned, then it is set to nil, which is what "command" in this instance gives you, in my understanding.
yeah, what he said.


So as not to be a bad doggy, I'm modifing all of my code now.

^c Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

CADaver

  • Guest
Re: Re-defining blocks
« Reply #13 on: July 26, 2006, 03:57:01 PM »
So as not to be a bad doggy, I'm modifing all of my code now.
Don't expect me to back up and fix all of mine...