Jump to content

Recommended Posts

Posted

Buzzard,

 

After some more thought, this is old tech, but probably a bit more accurate. It can deal with MINSERTs and nested INSERTS. It also contains the BLOCK name.

 

And it also jogged my memory.

 

[b][color=BLACK]([/color][/b]defun c:phoneatt [b][color=FUCHSIA]([/color][/b]/ wf rf nl i fl[b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]setq wf [b][color=NAVY]([/color][/b]open [color=#2f4f4f]"PHONEATT.TXT"[/color] [color=#2f4f4f]"w"[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]foreach v '[b][color=NAVY]([/color][/b][color=#2f4f4f]"BL:NAME  C032000"[/color] [color=#2f4f4f]"DT  C080000"[/color]
              [color=#2f4f4f]"MT  C080000"[/color]      [color=#2f4f4f]"ST  C080000"[/color][b][color=NAVY])[/color][/b]
     [b][color=NAVY]([/color][/b]write-line v wf[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]close wf[b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]command [color=#2f4f4f]"_.ATTEXT"[/color] [color=#2f4f4f]"C"[/color] [color=#2f4f4f]"PHONEATT"[/color] [color=#2f4f4f]"PHONES"[/color][b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]setq rf [b][color=NAVY]([/color][/b]open [color=#2f4f4f]"PHONES.TXT"[/color] [color=#2f4f4f]"r"[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]setq nl [b][color=MAROON]([/color][/b]read-line rf[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]setq i 1[b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]while [b][color=MAROON]([/color][/b]/= [color=#2f4f4f]","[/color] [b][color=GREEN]([/color][/b]substr nl i 1[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
               [b][color=MAROON]([/color][/b]setq i [b][color=GREEN]([/color][/b]1+ i[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]and [b][color=MAROON]([/color][/b]member [b][color=GREEN]([/color][/b]strcase [b][color=BLUE]([/color][/b]substr nl 2 [b][color=RED]([/color][/b]- i 3[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b]
                    '[b][color=GREEN]([/color][/b][color=#2f4f4f]"DATA"[/color] [color=#2f4f4f]"VOICE"[/color] [color=#2f4f4f]"VOICE/DATA"[/color] [color=#2f4f4f]"FIBER"[/color][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
             [b][color=MAROON]([/color][/b]if [b][color=GREEN]([/color][/b]assoc nl fl[b][color=GREEN])[/color][/b]
                 [b][color=GREEN]([/color][/b]setq fl [b][color=BLUE]([/color][/b]subst [b][color=RED]([/color][/b]cons nl [b][color=PURPLE]([/color][/b]1+ [b][color=TEAL]([/color][/b]cdr [b][color=OLIVE]([/color][/b]assoc nl fl[b][color=OLIVE])[/color][/b][b][color=TEAL])[/color][/b][b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b]
                                 [b][color=RED]([/color][/b]assoc nl fl[b][color=RED])[/color][/b] fl[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b]
                 [b][color=GREEN]([/color][/b]setq fl [b][color=BLUE]([/color][/b]cons [b][color=RED]([/color][/b]cons nl 1[b][color=RED])[/color][/b] fl[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]close rf[b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]prin1 fl[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]

You do end up with 2 new files on your hard drive. Hopefully they don't step on any toes.

 

The output is still an associative list ( fl ) that needs to be dealt with. -David

  • Replies 61
  • Created
  • Last Reply

Top Posters In This Topic

  • The Buzzard

    31

  • Lee Mac

    22

  • David Bethel

    6

  • borgunit

    1

Posted

David,

 

These lines below look like an attribute template file.

 

  [b][color=fuchsia]([/color][/b]foreach v '[b][color=navy]([/color][/b][color=#2f4f4f]"BL:NAME  C032000"[/color] [color=#2f4f4f]"DT  C080000"[/color]
              [color=#2f4f4f]"MT  C080000"[/color]      [color=#2f4f4f]"ST  C080000"[/color][b][color=navy])[/color][/b]

 

Do I need to set up a template?

 

The Buzzard

Posted

Again this type of coding is all new to me.

So I need to break it all down line by line.

Its amazing how many different way there are to do the same thing.

Posted

Buzzard,

 

No, the program will set it up automatically. A file named phoneatt.txt should appear in your working directory along with a file phones.txt. It contains the attext data.

 

I am running into a problem. It works correctly in R12, R13 & R14 but is giving flakey results in 2000. VDATA is not showing up here.

 

Hmmm...

 

Also voice/data is not a valid BLOCK name. I changed it to VDATA.

[b][color=BLACK]([/color][/b]defun c:phoneatt [b][color=FUCHSIA]([/color][/b]/ wf rf nl i fl[b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]setq wf [b][color=NAVY]([/color][/b]open [color=#2f4f4f]"PHONEATT.TXT"[/color] [color=#2f4f4f]"w"[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]foreach v '[b][color=NAVY]([/color][/b][color=#2f4f4f]"BL:NAME  C016000"[/color] [color=#2f4f4f]"DT  C016000"[/color]
              [color=#2f4f4f]"MT  C016000"[/color]      [color=#2f4f4f]"ST  C016000"[/color][b][color=NAVY])[/color][/b]
     [b][color=NAVY]([/color][/b]write-line v wf[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]close wf[b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]command [color=#2f4f4f]"_.ATTEXT"[/color] [color=#2f4f4f]"C"[/color] [color=#2f4f4f]"PHONEATT"[/color] [color=#2f4f4f]"PHONES"[/color][b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]setq rf [b][color=NAVY]([/color][/b]open [color=#2f4f4f]"PHONES.TXT"[/color] [color=#2f4f4f]"r"[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]setq nl [b][color=MAROON]([/color][/b]read-line rf[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]setq i 1[b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]while [b][color=MAROON]([/color][/b]/= [color=#2f4f4f]","[/color] [b][color=GREEN]([/color][/b]substr nl i 1[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
               [b][color=MAROON]([/color][/b]setq i [b][color=GREEN]([/color][/b]1+ i[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]and [b][color=MAROON]([/color][/b]member [b][color=GREEN]([/color][/b]strcase [b][color=BLUE]([/color][/b]substr nl 2 [b][color=RED]([/color][/b]- i 3[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b]
                    '[b][color=GREEN]([/color][/b][color=#2f4f4f]"DATA"[/color] [color=#2f4f4f]"VOICE"[/color] [color=#2f4f4f]"VDATA"[/color] [color=#2f4f4f]"FIBER"[/color][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
             [b][color=MAROON]([/color][/b]if [b][color=GREEN]([/color][/b]assoc nl fl[b][color=GREEN])[/color][/b]
                 [b][color=GREEN]([/color][/b]setq fl [b][color=BLUE]([/color][/b]subst [b][color=RED]([/color][/b]cons nl [b][color=PURPLE]([/color][/b]1+ [b][color=TEAL]([/color][/b]cdr [b][color=OLIVE]([/color][/b]assoc nl fl[b][color=OLIVE])[/color][/b][b][color=TEAL])[/color][/b][b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b]
                                 [b][color=RED]([/color][/b]assoc nl fl[b][color=RED])[/color][/b] fl[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b]
                 [b][color=GREEN]([/color][/b]setq fl [b][color=BLUE]([/color][/b]cons [b][color=RED]([/color][/b]cons nl 1[b][color=RED])[/color][/b] fl[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]close rf[b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]prin1 fl[b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]

I don't have any newer releases to test it on.

 

Lee, MINSERTs are a single multiple INSERT entity, setup by rows and columns. They can be very useful but can't be exploded and you have to calculate the total number for counting routines.

 

-David

PHONEATT.DWG

Posted

David

 

I just tested it out, Its a comma delimited text file. I remember this from release 9. Although I did not plan on exporting the information,

this routine has other uses.

 

My brain hurts!!!

Posted

David,

 

I did not have a problem with the first drawing you posted. I have downloaded the second drawing anyway. This routine will select everything at once although I was planning on using a dialog with a popup menu and selecting only a specific symbol. Either way once I have something that works for me I will adust my dialog accordingly.

 

I Thank You & Lee For All This Great Help,

I have alot to digest at the moment, I am studying everything line by line so that I will have a full understanding.

 

The Buzzard

Posted

If I remember correctly, ATTEXT exports all ATTRIB data that has matching tag names regardless.

 

You can manipulate the BLOCK name list in this test to filter out unwanted INSERTS

 

[b][color=NAVY]([/color][/b]and [b][color=MAROON]([/color][/b]member [b][color=GREEN]([/color][/b]strcase [b][color=BLUE]([/color][/b]substr nl 2 [b][color=RED]([/color][/b]- i 3[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b]
           '[b][color=GREEN]([/color][/b][color=#2f4f4f]"DATA"[/color] [color=#2f4f4f]"VOICE"[/color] [color=#2f4f4f]"VDATA"[/color] [color=#2f4f4f]"FIBER"[/color][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]

Good Luck -David

Posted

I got it now, But as I had explained before, This type of coding is new to me. I am trying to develope an understanding by disecting the code. It will take a little time, But I will get it. Thank you for pointing the previous post out to me, I do not like to go on my own assumptions.

 

The Buzzard

Posted

I'm sure you'll get the hang of it Buzzard - you seem like a clever fellow.

Posted

Clever Fellow?

 

Im just a Buzzard.

 

So does that mean programming must be for the birds?

 

Who knows?

  • 2 weeks later...
Posted

Ok I got this done, But not the way I had first intended. I am now filtering by way of block name and layer. I decided not to go with attributes at this point, Because I was having problems get the result I wanted. The program now give me the answers that I am looking for.

 

But now I am trying to change the way the result is displayed. At this moment the program displays an ALERT with the quantities. I would like to take the result in variable QTY and place it in a stationary block with a default 0 value and replace it with the result from QTY.

 

I know this is possible, But I am lost at this point. I am posting the program with the dialog for easy input. Please ignore the additional function to count cables as I am in the process of working on this. I have intentionally left out the function for it at this point. Any help offered would be greatly appreciated.

 

Thanks in advanced,

The Buzzard

CDL.zip

Sample-Telco.dwg

Posted

Put this in your code somewhere: (takes one argument ~ new attribute string)

 

(defun attupd (nVal / ss bEnt)
 (if (and (setq ss (ssget "X" (list (cons 0 "INSERT")(cons 2 "BOM")(cons 66 1)
   (if (getvar "CTAB")
     (cons 410 (getvar "CTAB"))
     (cons 67 (- 1 (getvar "TILEMODE")))))))
   (= (sslength ss) 1))
   (progn
     (setq bEnt (entget (entnext (ssname ss 0)))
       bEnt (subst (cons 1 nVal) (assoc 1 bEnt) bEnt))
     (entmod bEnt))
   (princ "\n<!> None/Multiple BOM Blocks Found <!>"))
 (princ))

May have to regen to see result :)

Posted

Thank You Lee_Mac for getting back to me.

 

I placed the code in the program as a separate function and called it from my CDL_CDL function, But nothing seems to happen. Do I need to modify this code or will it work as is or maybe I wrote the argument wrong. Not sure if I am doing this correctly. The program is too large to post with code tags. Could you please give me some direction as to how this is suppose to work?

 

 

I would appreciate alot.

The Buzzard

Posted

Hey Buzzard, the program definitely works when the argument is specified correctly - I have tested it myself (also, there isn't much that can go wrong...)

 

Specify the argument as a string:

 

i.e.

 

(attupd "new_attribute_value")

 

in your case:

 

(attupd (rtos QTY)) ; if QTY is a number

 

And as I say, you may need to include a REGEN to see the result.

Posted

I am sending a zip file with the program so you can see what I did.

I am getting ; error: too few arguments

Not sure what I am leaving out?

QTY is a numerical value and I wrote it as you have shown.

CDL.zip

Posted

Hmm... that is weird that it is not working:

 

maybe this: but I can't see it making much difference, but worth a try:

 



;;;////////////////////////////////////////////////////////////////////////////////////

;;; 04 - Output Function - Count Drop Locations.                                       ;Function Description

(defun CDL_CDL ()                                                                      ;Define Function

 (if                                                                                  ;Start of if
   (= SM "DM")                                                                        ;Selection Method = Drop/Mount
   (setq CDLQTY (ssget "x" (list (cons 2 BNAME)))))                                   ;Set CDLQTY, Get all blocks, Filter by block name

 (if                                                                                  ;Start of if
   (= SM "DMA")                                                                       ;Selection Method = Drop/Mount/Application
   (setq CDLQTY (ssget "x" (list (cons 2 BNAME)(cons 8 LNAME)))))                     ;Set CDLQTY,Get all blocks, Filter by block name and layer name

 (progn                                                                             ;Start of progn
   (setq QTY (sslength CDLQTY))                                                     ;Count the blocks and put into variable QTY
   (attupd (rtos QTY 2 0))
 )
 (command "regenall" "")
 (princ)                                                                              ;Exit quietly
)                                                                                      ;End of Define Function


;;;////////////////////////////////////////////////////////////////////////////////////

(defun attupd (nVal / ss bEnt)
 (if (and (setq ss (ssget "X" (list (cons 0 "INSERT")(cons 2 "BOM")(cons 66 1)
   (if (getvar "CTAB")
     (cons 410 (getvar "CTAB"))
     (cons 67 (- 1 (getvar "TILEMODE")))))))
   (= (sslength ss) 1))
   (progn
     (setq bEnt (entget (entnext (ssname ss 0)))
       bEnt (subst (cons 1 nVal) (assoc 1 bEnt) bEnt))
     (entmod bEnt))
   (princ "\n<!> None/Multiple BOM Blocks Found <!>"))
 (princ))


Posted

The Weird thing is that I tested the routine on the drawing you posted, with the block "0".

 

and I just changed the attribute using:

 

(attupd "123")

 

and

 

(attupd "456")

 

And everything worked fine, so I can't see why you are having problems. :(

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...