Author Topic: Insert Blocks with attributes Using Script  (Read 5643 times)

0 Members and 1 Guest are viewing this topic.

M-dub

  • Guest
Insert Blocks with attributes Using Script
« on: August 09, 2004, 03:09:03 PM »
Hey All...
Brain :fart: here...

I used to use scripts to create entire drawings (years ago) and now, I can't seem to get this script to fill out a single block correctly! :x
I've got a block I want to insert all over the place and in that block are 14 different attributes.  Some of the attributes are empty though.  It works alright if I leave all of them blank, but the first one with text in it is the point where the script screws up (rather, the point where I screwed up the script :roll: )


~~~FORGET THAT PART~~~


(I just remembered  :roll: )
Now I need to know if there's a way to find and replace " " with a carriage return using Notepad or something similar.

I need to change this:
Code: [Select]
-INSERT VENT_SOURCE 286.8,107.1    AB1 AB-1  286.8 107.1 0.05  0.3  open pipe    
into this:
Code: [Select]
-INSERT
VENT_SOURCE
286.8,107.1



AB1
AB-1

286.8
107.1
0.05

0.3

open pipe

(I've got about 1000 blocks here so I'd rather not do it all manually)

Thanks a million!
Mike
Anyone know of something that might help me here?

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Insert Blocks with attributes Using Script
« Reply #1 on: August 09, 2004, 03:35:42 PM »
Quote from: M-dub
~~~FORGET THAT PART~~~

Now I need to know if there's a way to find and replace " " with a carriage return using Notepad or something similar.

This is a no-brainer using any capable text editor that does regular expressions.

For example in Textpad use search and replace [F8], toggle on "Regular exdpressions" ... Search for " ", Replace with "\n" ...



www.textpad.com

A fun alternative is to use lisp to read in the file, do the appropriate search and replace, and write it all back out.

Finally, you know you can define and call lisp from scripts right? (Which makes conserns about carriage returns somwhat moot).

Cheers,

M.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

M-dub

  • Guest
Insert Blocks with attributes Using Script
« Reply #2 on: August 09, 2004, 03:55:14 PM »
Thanks a lot, Michael.
I'm working on another way of doing it...I've got to collect ALL of my thoughts on this one.  Here's the situation:
We have a contractor who's adding all of these blocks for vent locations on our site plan (it's not a real precise location) and the block is basically just a dot with a label.  What he's doing after he inserts all of the blocks, he uses the ol' ATTEXT command to get the Label, and the X & Y co-ordinates.  He then brings that into Excel and fills out all of the other info (11 additional fields).  I want to have all of that info in the block (for another reason), so what I think will be the best solution will be to wait until he has finished placing all of the blocks and populating his spreadsheet.  Then, I will add the new attributes (invisible) to the block and redefine it in the drawing and using the new ATTOUT and ATTIN Express Tools commands, fill in the rest of the info in each block.

I think I said that right...although I'm not sure if it's the best idea yet or not.  We'll see.  Thanks again, Michael.

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
Insert Blocks with attributes Using Script
« Reply #3 on: August 09, 2004, 03:58:25 PM »
from this to .......
-INSERT VENT_SOURCE 286.8,107.1    AB1 AB-1  286.8 107.1 0.05  0.3  open pipe

.... this
-INSERT
VENT_SOURCE
286.8,107.1



AB1
AB-1

286.8
107.1
0.05

0.3

open
pipe


in vim it would be  ":%s/ /CTRL+v<enter>/g"
if you have like 20 of these files open in the same session of Vim you would do this;
":bufdo %s/ /CTRL+v<enter>/g" and it will process each one for you.
TheSwamp.org  (serving the CAD community since 2003)