-
Controlling the Machine is no longer being updated. Don't worry, though, you can still follow Nate Holt at his new blog, AutoCAD Electrical Etcetera. You'll find it at http://nateholt.wordpress.com. Or you can subscribe to his feed to get latest words of wisdom automatically: http://nateholt.wordpress.com/feed/. You also can continue to view the Controlling Machine archives for Nate's AutoCAD Electrical tips and tricks.
-
Reformat Wire From/To report into a tallied Wire Count report - AutoCAD Electrical
October 31, 2008, 09:03 AM Nate HoltHere is another example of AutoCAD Electrical's report "User Post" capability can step in and service a user's custom reporting needs.
In this example, the user wants a tallied list of wires used in his AutoCAD Electrical project drawing set, tallied by wire number and by wire type (i.e. the wire "layer" name).
The closest standard report would be the "Wire From/To" report that lists a line item for every from/to wire connection in the project. This includes wire number, wire type (i.e. wire layer), component and pin number connection at each end, etc. BUT, the report is not "tallied". For example, wire number "309B" with a wire type of "WHT_16_AWG" might be carried on a wire network that interconnects 27 devices yielding potentially 26 line item entries in the normal from/to report.
But, the user wants to condense these entries down so that each wire number / wire type combination is one line entry with a "quantity" column, sort of like a "wire number BOM" report.
Here is how
Step 1 - figure out the name of the existing "user post" utility associated with the Wire From/To report. Run the report and then hit the "User Post" button on the report dialog. Look down in the command window. The path/name of the user post utility is shown here. This is the file we will alter along with the "dialog control" file - same name but ".dcl" extension.

Step 2 - Get into the folder shown above. Make backup copies of wirefrm2.lsp and wirefrm2.dcl (just in case!)
Step 3 - Open wirefrm2.dcl with an ASCII text editor or the AutoCAD Visual Lisp editor. Make and save changes shown in bold below. This will add a new "Wire Count" option to the little dialog that pops up when we select "User Post" for the Wire From/To report.
main_select : dialog
{
label=/*wirefrm2_dcl_001*/"Report Data Post-processing Options";
:paragraph
{
:text_part{
label=/*wirefrm2_dcl_002*/"Select options(s) to apply to the report's data";
}
:text_part{
label=/*wirefrm2_dcl_003*/"before passing it back to the report display dialog.";
}
:text_part{label="";}
:text_part{
label=/*wirefrm2_dcl_004*/"(To modify these user options, edit the Post-process";
}
:text_part{
label=/*wirefrm2_dcl_005*/" utility file listed in the AutoCAD command line window)";
}
:text_part{label="";}
}
:toggle{key="user1";
label=/*wirefrm2_dcl_007*/"Substitute wire color/gauge label text for LAYER names";
}
:toggle{key="user2";
label=/*wirefrm2_dcl_012*/"Report only selected INST values";
}
:toggle{key="user3";
label=/*wirefrm2_dcl_009*/"Report only non-cable connections";
}
:toggle{key="user4";
label=/*wirefrm2_dcl_013*/"Report only selected wire types";
}
:toggle{key="user5";
label=/*wirefrm2_dcl_xxx*/"Format into wire count report - (WIRENO,LOC1=count, and WLAY1)";
}
ok_cancel;
}Step 4 - Open wirefrm2.lsp file. Add three lines shown in bold below to support the new toggle on the above dialog:
; -- main routine --
(setq rtrn nil)
; AutoCAD Electrical passes the report displayed data as a list of lists of lists in variable
; called wd_rdata. The first element of this list is the list of lists
; report data. The 2nd element is future (at this time).
(if (AND wd_rdata (car wd_rdata) (listp (car wd_rdata)))
(setq wd_rdata (car wd_rdata))) ; just go with first list of lists (report data)
; Create and reference a ".dcl" file, on-the-fly
; (setq user_1 "1") ; default to 1st user entry toggled on
(setq user_1 "0") ; default toggle OFF
(setq user_2 "0")
(setq user_3 "0")
(setq user_4 "0") ; ** 25-Mar-06 NEHolt
(setq user_5 "0")
; Look for dcl file of same name, open if found.
(setq cancel nil)
; see if running as pre-process or auto report. won't work for those below that require selection from dialog
(if GBL_wd_postprocess
(progn
(if (listp GBL_wd_postprocess)
(progn
(if (> (length GBL_wd_postprocess) 1)
(setq param_lst (cadr GBL_wd_postprocess)) ; optional for any selections within this function
(setq param_lst nil)
)
(setq GBL_wd_postprocess (car GBL_wd_postprocess)) ; should be which one to run
) )
(if (= (type GBL_wd_postprocess) 'INT) (setq GBL_wd_postprocess (itoa GBL_wd_postprocess)))
(cond
((= GBL_wd_postprocess "1") (setq user_1 "1"))
((= GBL_wd_postprocess "2") (setq user_2 "1"))
((= GBL_wd_postprocess "3") (setq user_3 "1"))
((= GBL_wd_postprocess "4") (setq user_4 "1"))
((= GBL_wd_postprocess "5") (setq user_5 "1"))
(T (setq cancel 1)) ; not a valid value
)
) )
; Look for dcl file of same name, open if found.
(if (AND (not GBL_wd_postprocess) ; otherwise bypass dialog
(setq dclnam (c:ace_find_file "wirefrm2.dcl" 16))) ; 16=display error dialog if file not found
(progn
(setq dcl_id (load_dialog dclnam))
(if (new_dialog "main_select" dcl_id)
(progn
(set_tile "user1" user_1) ; set toggles per defaults above
(set_tile "user2" user_2)
(set_tile "user3" user_3)
(set_tile "user4" user_4) ; ** 25-Mar-06 NEHolt
(set_tile "user5" user_5)
(action_tile "user1" "(setq user_1 $value)")
(action_tile "user2" "(setq user_2 $value)")
(action_tile "user3" "(setq user_3 $value)")
(action_tile "user4" "(setq user_4 $value)") ; ** 25-Mar-06 NEHolt
(action_tile "user5" "(setq user_5 $value)")
(action_tile "cancel" "(setq cancel 1)")
(start_dialog)
(unload_dialog dcl_id)
) ) ) )... and add this new section which is triggered by selecting the new report option. This section accumulates the wire number / wire layer combinations, counts them up, and reformats the report into a tallied wire count list ( ! )
) )
) )
) )
(if (= user_5 "1") ; reformat the whole report as a "wire number/count" report
(progn
(setq rtrn nil)
(setq wnum_lst nil)
(setq cnt_lst nil)
(foreach xx wd_rdata
; (nth 0 xx) = WIRENO
; (nth 7 xx) = WIRELAY (tied to the "From" component)
(cond
((setq x (member (list (nth 0 xx)(nth 7 xx)) wnum_lst))
; Repeated wire number / wire layer combo. Increment count in cnt_lst
(setq cnt (nth (- (length wnum_lst)(length x)) cnt_lst))
(setq cnt (1+ cnt))
; Push incremented value back into the list
(setq cnt_lst (wd_nth_subst (- (length wnum_lst)(length x)) cnt cnt_lst))
)
(T ; New wire number / Wire layer combo
(setq wnum_lst (cons (list (nth 0 xx) (nth 7 xx)) wnum_lst))
(setq cnt_lst (cons 1 cnt_lst)) ; start with a count of 1
)
)
)
; Push the wire number and count value out to the report
(setq ix 0)
(foreach xx wnum_lst
(setq lst (list (nth 0 xx) ; wire number - index 0 item in list
(itoa (nth ix cnt_lst)) ; count - index 1 item in list
"" "" "" "" "" ; blank field placeholders for items 2-6
(nth 1 xx) ; wire layer into 7th item of list
)
)
(setq rtrn (cons lst rtrn))
(setq ix (1+ ix))
)
(setq rtrn (reverse rtrn)) ; put back into original order
(setq wd_rdata rtrn) ; fresh copy for possible further processing
) )
)
)
(c:wd_rtrn_2wd rtrn) ; return post-processed list back to AutoCAD Electrical's report dialog
)If this is too daunting, download the modified files here and push into the above folder:
files/22301_22400/22303/file_22303.dcl and rename to wirefrm2.dcl
files/22301_22400/22304/file_22304.lsp and rename to wirefrm2.lsp
Step 5 - TEST! - run the Wire From/To report and let it display in the dialog. Hit the "User Post" button. You should see your new, modified dialog pop up with a fifth option:

... toggle this and hit OK. In main report dialog select "Change Report Format" and show only the WIRENO, LOC1, and WLAY1 fields. Hit OK. Sort by LOC1 (quantity) and by WIRENO. Hit OK. There it is!

Comments
-
January 22, 2009 10:32 AM Humberto Penza
Yesterday my company installed me Autocad Electrical 2009. Testing it I had 5 errors for the momment and a big problem with the new version of the FIND command. Por ahora lo que le ví es lo siguiente: 0. Tiene muchas mejoras cosméticas. Especialmente el Ribbon que no le veo utilidad en la parte eléctrica y se ve que poreso viene apagado por defecto. 1. Cuando se abre por primera vez y quiero ver las diferencias con el acade2008 da error en el launchpad porque falta en la instalación las páginas web de ayuda dicen esas cosas. 2.Da error al cargar las librerías de componentes porque no las instalaron. No están en las carpetas donde el programa las busca. 3. Me puse a trabajar en un proyecto que estoy terminando en la parte del reporte del listado de materiales BOM y en un momento se colgó AcePmComServer6.exe y me aparecieron 5 veces mensajes de error. Luego de eso se nececita derrar el Autocad y volver a abrirlo para que funcionen nuevamente las funciones eléctricas del acad que quedaron bloqueadas. 4. El comando FIND de buscar y reemplazar dentro de los objetos seleccionados cambió en el acade 2009 . Probé cliqueando todas las opciones posibles y ya no busca más dentro de los atributos ocultos de los bloques de componentes. Esta función estaba siendo muy usada y no encuentro dentro de los comandos de buscar y reemplazar del electrical algo que sustituya la potencialidad que tenía esta función del Autocad Electrical 2008 que fue restringida a buscar solo en los elementos visibles en el autocad 2009. Esto es bastante importante. Yo que no cambiaría el Autocad Electrical 2008 por el 2009 si no encuentro algo que solucione este problema. Paso a explicar por que: Supongamos que tengo un dibujo hecho en que en las descripciones ocultas en el dibujo pero visibles en el listado de materiales (por ejemplo en el campo DESC3), tengo los siguientes textos: FASE A - 150kV FASE B - 150kV FASE C - 150kV y quiero cambiarlas por: FASE A - 66V FASE B - 66kV FASE C - 66kV con el comando Find del Autocad electtrical 2008 selecciono los componentes escribo find, buscar 150 y reemplazar por 66, luego le doy una actualización a la base de datos del electrical. Eso aún no lo pude hacer así de fácil con el autocad electrical 2009 ya que tendría que poner visibles todos los atributos y luego pasarlos a invisibles. Tampoco supe hacerlo usando el comando WD_FR ya por lo que vi trabaja con el contenido completo del atributo y no parte del mismo. En definitiva; si no encuentro una solución a esto y no veo ventajas significativas en el Electrical 2009 me quedaría con el 2008. 5.Hay cambios en los menúes de edición de componentes. Aparecen funciones dentro de ellos que no se para que son y como no anda lo del punto 1 tampoco puedo saber para que son. Supongo que se trata de alguna mejora que no se como funciona. 6. En cuanto a mejoras operativas: Sigue habiendo dificultad de actualización de la base de datos *.mdb. En el reporte de todo el proyecto aún no encuentro los datos actualizados de algunos componentes que ya actualicé en una hoja en particular y que aparecen bien en el reporte de esa hoja en particular. Aparecen en el reporte algunos componentes que no se donde están y que aún no encontré la forma de navegar para buscarlos. Continuo buscando como solucionar ese tema. Best regards Humberto Penza Electrical engineer Electrical Protection engineering management
You must be logged in to post a comment.