AutoCAD Electrical Forum
Welcome to Autodesk’s AutoCAD Electrical Forums. Share your knowledge, ask questions, and explore popular AutoCAD Electrical topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Last wire number --> Title Block update

0 REPLIES 0
Reply
Message 1 of 1
Anonymous
224 Views, 0 Replies

Last wire number --> Title Block update

Someone asked about mapping the "last wire number used" out to the title block. I can't find the thread so hopefully that person will see this note. The following little Lisp utility can be referenced by the title block mapping file (the ".wdt" file) or encoded into your title block's "WD_TB" invisible attribute value (if that's the method you use to link your title block to AcadE). When this utility runs, it returns the last wire number it finds on the drawing. If no wire numbers found then it returns blank. It excludes wire numbers that are associated with wire networks having "Destination" wire signal arrows on them (meaning that the actual wire number assignment was made on some other drawing). This may or may not work for you. Give it a shot. Don't be afraid to modify the Lisp utility to make it work the way you want. Nate Holt. ==== Setting this up using the ".WDT" mapping file method ==== Let's say your title block's "last wire number" attribute is called "LASTWIRENUM". In your AcadE to title block mapping file (ex: default.wdt), you'd set this up by adding the following line to the ".wdt" file: LASTWIRENUM = (if (boundp 'c:lastwnum)(c:lastwnum)"") The "boundp" call verifies that the lisp routine has been apploaded. If found then it runs (c:lastwnum), if not found then it just returns "" as the last wire number value. ==== Setting this up using the WD_TB invisible attribute method ==== Let's say your title block's "last wire number" attribute is called "LASTWIRENUM" and your title block also carries the WD_TB attribute where you encode all of the mapping info. Add the following to the end of the WD_TB attribute's value: ;LASTWIRENUM = (if (boundp 'c:lastwnum)(c:lastwnum)"") === Lisp routine - save to a file. Make sure it gets APPLOADED. ; 22-Mar-04 NEHolt created (defun c:lastwnum ( / ss exclude_num_lst ix slen rtrn wireno maxnum en val) ; Scan current dwg and find "last wire number" used. Drawing needs to have been processed ; by AcadE's AUTO WNUMS command or wire numbers manually inserted using AcadE's EDIT WNUM ; command. This routine can be encoded into AcadE's title block update mapping file to ; automatically populate a target attribute in the title block with the last wire number ; used on the drawing. (setq rtrn "") ; default to return a blank space if no wire numbers found (if (not GBL_wd_m) (wd_cfg_read_dwg_params)) ; read WD_M block if necessary ; Step 1 - get list of all wire numbers found on DESTINATION signal arrows. These numbers ; will be excluded from the calculation because the wire number was assigned on some ; other drawing. (setq exclude_num_lst nil) (setq maxnum 0) ; Destination arrow symbols are named HAxDn.dwg where x=digit 1-9, n=digit 1-4 ; Scan all dwg and build a selection set of all Destination signal arrow symbol inserts (setq ss (ssget "_X" '((-4 . "")))) (if (/= ss nil) (progn ; some Destination signal arrows found. Process them and grab the copy ; of the wire number that is carried on each symbol. Add to a list of ; wire numbers that will be excluded from consideration. (setq slen (sslength ss)) ; number of block inserts found (setq ix 0) ; counter (while (< ix slen) ; process each Destination signal arrow block insert (setq en (ssname ss ix)) ; get next block entity name from the selection set ; Look for attribute WIRENO on this arrow symbol. Get its value (wire number) (setq wireno (c:wd_getattrval en "WIRENO")) (if (AND wireno (/= wireno "")) (progn ; save wire number in the "exclude" list (setq exclude_num_lst (cons wireno exclude_num_lst)) ) ) (setq ix (1+ ix)) ; increment counter ) (setq ss nil) ; release the selection set ) ) ; Step 2 - get all wire number block inserts on current drawing (setq ss (ssget "_X" '((-4 . "")))) (if (/= ss nil) ; Some wire numbers found on drawing, continue (progn (setq slen (sslength ss)) ; number of wire number block inserts on dwg (setq ix 0) (while (< ix slen) (setq en (ssname ss ix)) ; get next wire number block/insert entity name ; Grab wire number off of this wire number block insert. (setq wireno (c:wd_getattrval en "WIRENO*")) ; could be WIRENO or WIRENOF for "fixed" (if (AND wireno (/= wireno "")) ; wire number is not blank (progn ; Make sure that this wire number is not one we're excluding (i.e. Destination wnum) (if (not (member wireno exclude_num_lst)) (progn ; okay, good wire number to process (setq val (atoi wireno)) ; convert wire number to integer value (if (> val maxnum) (progn ; this wire number is biggest so far. Save it. (setq rtrn wireno) ; return highest wire number so far (setq maxnum val) ; save highest value so far ) ) ) ) ) ) (setq ix (1+ ix)) ) (setq ss nil) ; release selection set ) ) rtrn ; return "" or highest wire number found on this dwg )
0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost