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: 

Retrieve list of all wire labels using AutoLISP

4 REPLIES 4
Reply
Message 1 of 5
zwhiteley
253 Views, 4 Replies

Retrieve list of all wire labels using AutoLISP

I'm setting up a custom script to number our wires according to our internal format (no, the in-built wire numbering doesn't work for this). I want to fetch a list of all the existing wire labels from my drawing using AutoLISP, does anyone know a command for this?

 

I had thought that 'ace_wnum_find' should be able to achieve this functionality (as it states that the dwg_wirenum_lst command should fetch a list of all existing wire numbers), but that is proving incredibly frustrating to find any sort of decent documentation on the format it expects that command in.

 

zwhiteley_0-1658181296904.png

 

4 REPLIES 4
Message 2 of 5
vladop
in reply to: zwhiteley

Hi zwhiteley,

"dwg_wirenum_lst" is not a function but one of the possible parameter forms of the "dwg_wirenum_lst " function.

This function tests whether the wire number has been used. Which wire number is tested is defined by supplied parameter. Тhe simplest example is given in the help file:

 

Check whether wire number "1000" is in use.

(setq wnum "1000")

(setq return (c:ace_wnum_find wnum))

; If return = "1000" then the wire number is NOT in use

; If return > "1000" then the return value is the next available wire number

 

This function is used when assigning a new wire number to check if the that wirenumber is already in use.

 

----------------------------------------------------------------------------------------------------------------------------

 

You can use "wd_oledb_select" to query scratch database e.g.:

 

(setq fnam (c:wd_mdb_get_proj_scratch_dbnam nil))
(wd_oledb_select fnam "SELECT [WNUM.DWGIX], [FILETIME.DWGNAME], [WNUM.HDL], [WNUM.WIRENO] FROM [WNUM], [FILETIME] WHERE [WIRESEG.DWGIX]=[FILETIME.DWGIX] ORDER BY [WIRESEG.DWGIX]")

 

----------------------------------------------------------------------------------------------------------------------------

 

But first you should check Nate Holt posts:

Enhanced wire number tags based on connected components – AutoCAD Electrical | Nate Holt's Blog (wor...

Terminal AutoCAD: AutoCAD Electrical - Wire From/To Annotation On the Schematic (myacade.blogspot.co...

Tutorial – Automatic Wire Annotation from Schematic to W/D (Part 1) – AutoCAD Electrical | Nate Holt...

Tutorial – Using Excel with AutoCAD Electrical (Part 4 – Wire numbers) | Nate Holt's Blog (wordpress...

etc...

 

Older posts (before July 2009) are no longer available. Nate knows why.

 

April 2009
IEC-style Wire Numbering

 

October 2008
X-Y Grid-based Wire Numbering – based on pick points

 

April 2008
Match Wire Number text to Wire Color
Extra wire number display – on component connections

 

June 2007
Auto wire number tag removal on cabled wire networks

 

September 2006
PLC I/O Wire Numbering based upon “Slot” + I/O Pin Number

 

July 2006
Special PLC Address-based Wire Numbers

 

Regards,

Vladimir

 

Message 3 of 5
zwhiteley
in reply to: zwhiteley

Thanks for the reply Vladimir. I just reread the documentation on ace_wnum_find and realised that dwg_wirenum_lst is a user supplied list and not a return. I suppose my question then is where are you supposed to get this list from? Do I have to manually store a value somewhere every time I number a wire? Alternatively, am I able to call ace_wnum_find and use wild cards in the searched wire number?

 

I also don't appear to be able to find any documentation on wd_oledb_select?

 

I was aware of many of Nates posts, and have used a few of them as reference material, however our structure consists of strcat(Functional_Identifier "-" Harness_Identifier Wire_Number " " Layer_Name), which is quite different to many of the schemes he uses.

 

The bit I am running into trouble on is the wire number. I have everything else working, but I need to be able to check if the wire number has been used yet. The issue is that the wire numbers should be sequential for every wire sharing the same harness identifier, even if the rest of the label is different. eg 123-E51 RD-16 and 456-E51 GN-12 cannot coexist but 123-E51 RD-16 and 456-Y51 GN-12 can. Thus I need to be able to check what numbers have been used and what haven't. And I need to be able to add numbers at a later date, so I can't just sequential number everything and then use that as a reference, because old wires might change, causing dozens of drawings to have to be updated.

Message 4 of 5
vladop
in reply to: zwhiteley

I also don't appear to be able to find any documentation on wd_oledb_select?

 

API Help --> Section M - Project Database Service --> LISP --> WD_OLEDB_SELECT

Message 5 of 5
vladop
in reply to: zwhiteley

If you want only unique wire numbers:

(setq fnam (c:wd_mdb_get_proj_scratch_dbnam nil))
(wd_oledb_select fnam "[WNUM]" "DISTINCT [WIRENO]" "" "" 1)

 

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

Post to forums  

Technology Administrators


AutoCAD Beta