Author Topic: Renaming copied blocks  (Read 4496 times)

0 Members and 1 Guest are viewing this topic.

One Shot

  • Guest
Renaming copied blocks
« on: September 28, 2004, 12:56:31 PM »
Changing the names of a copied blocks. My idea would allow you to copy an block in your drawing and being able to change the name of it. It will still be the original block but with a different name.

One thing that I forget to suggest is that the new name should only be for block the was just picked. It should not change anything else.

I had something similar to this for Xrefs.  It works great. :?:

daron

  • Guest
Renaming copied blocks
« Reply #1 on: September 28, 2004, 01:02:37 PM »
Why don't you put some pseudo-code together?

One Shot

  • Guest
Renaming copied blocks
« Reply #2 on: September 28, 2004, 01:05:12 PM »
Quote from: Daron
Why don't you put some pseudo-code together?


How do you put pseudo-code together?  I

daron

  • Guest
Renaming copied blocks
« Reply #3 on: September 28, 2004, 01:16:48 PM »
Pseudo-code is the steps it takes to do what you want. i.e. Lunch time
Stomach rumbles
must save work first
get lunch out of bag
go to kitchen
cook food *
eat food *

Start simple, then break down large tasks, like:
what all do I need to cook food?
First, what is food? Think selection sets. Lunch today is ravioli.
* get out can-opener
open ravioli
get a bowl and fork
dump ravioli into bowl
set bowl in microwave
cook for 2 min.
put plate under hot bowl
eat.

Sorry if I sound unhelpful, I'm hungry. Think about it though. All the things I've mentioned can help you learn to write code and help others assist you when you are asking for help.

We all seem to like some pseudo-code. This helps us to understand exactly the direction you intend us to take should we decide to give it a whirl. That way we don't have to go through five trials to get it right.

One Shot

  • Guest
Renaming copied blocks
« Reply #4 on: September 28, 2004, 09:10:09 PM »
Daron, thank you!  This really hasn't helped.  I am just beginning to learn lisp.  I just started to learn today and I could really use the help with this.

SMadsen

  • Guest
Renaming copied blocks
« Reply #5 on: September 29, 2004, 04:58:36 AM »
I agree with Daron that some kind of pseudocoding would help get you started .. plus it would describe the problem alot better.

This could be how you'd do it at the command line:

Command: -INSERT
Enter block name or [?]: new_name=old_name
Specify insertion point or [Scale/X/Y/Z/Rotate/PScale/PX/PY/PZ/PRotate]:
etc....

Done deal. You could do this in AutoLISP with a very few basic functions, one of which would be the COMMAND function. So, in pseudocode it could look something like this:

- Ask for pick of an insert and get its entity name
- Perhaps: ask for new name of copied block
- Perhaps: ask for a point for future insertion, scale factors and rotation
- Get the entity data and extract the block name
- Construct string for input to INSERT command (tip: (strcat old_name "=" new_name))
- Use COMMAND "-INSERT" with string from previous step, insertion point, scale factors and rotation
- Lean back and watch your coworkers jaws drop

The perhaps' depend on where the information comes from; hardcoded, user input or otherwise.

Of course, you could go all the way and iterate through subentities (and attributes) - or simply use the EXPLODE method from ActiveX, which will deliver all on a silver platter - and build a new block from scratch. But the above would be a nice little exercise.

And I'm sure we could all chip in if you need help with the steps.

CADaver

  • Guest
Renaming copied blocks
« Reply #6 on: September 29, 2004, 07:48:11 AM »
Quote from: One Shot
Daron, thank you!  This really hasn't helped.  I am just beginning to learn lisp.  I just started to learn today and I could really use the help with this.
Just a note to the new-comers about this forum that is vastly different from most.  This place, the Swamp, is a fishing school, generally, it will teach you how to fish.  Often, they will help you land a fish you've already hooked and occasionally they will even offer a piece of fish to get you over a rough spot.  Then every now and again, someone will give you a fish.  What Daron offered was a first lesson in how to buy bait.

At least that's how I see it.

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
Renaming copied blocks
« Reply #7 on: September 29, 2004, 08:05:49 AM »
Quote from: CADaver
Just a note to the new-comers about this forum...


Perfect.......... can I use that please?
TheSwamp.org  (serving the CAD community since 2003)

CADaver

  • Guest
Renaming copied blocks
« Reply #8 on: September 29, 2004, 08:50:21 AM »
Quote from: Mark Thomas
Quote from: CADaver
Just a note to the new-comers about this forum...


Perfect.......... can I use that please?


[my best Curly impersonation]
Certainly
[/my best Curly impersonation]

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
Renaming copied blocks
« Reply #9 on: September 29, 2004, 08:51:14 AM »
Thank you sir.
TheSwamp.org  (serving the CAD community since 2003)

CADaver

  • Guest
Renaming copied blocks
« Reply #10 on: September 29, 2004, 08:51:59 AM »
Quote from: Mark Thomas
Thank you sir.
Sir?? who's that?

hudster

  • Gator
  • Posts: 2848
Renaming copied blocks
« Reply #11 on: September 29, 2004, 10:34:17 AM »
CAB already wrote a lisp that does what you want.

click on a block, give it a new name and it creates a new one on layer 0 with all coulours set to "byblock".

you can find it HERE

I love this lisp routine, it makes my life so much easier.
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

One Shot

  • Guest
Renaming copied blocks
« Reply #12 on: September 29, 2004, 11:51:37 AM »
Quote from: Hudster
CAB already wrote a lisp that does what you want.

click on a block, give it a new name and it creates a new one on layer 0 with all coulours set to "byblock".

you can find it HERE

I love this lisp routine, it makes my life so much easier.


Thank you for pointing me in the right direction. :!: