Programmatically creating AutoCAD Electrical symbols

TXACDE24
Contributor
Contributor

Programmatically creating AutoCAD Electrical symbols

TXACDE24
Contributor
Contributor

Hi,

What else do we need to do other than creating the needed Attribute References for the required attributes and wire connections for a custom symbol created by code?

TXACDE24_1-1717948367347.png

I have a symbol with all four wire connection related attributes (TERM.. and X.TERM..), but it does not auto connect to wires when using it.

TXACDE24_0-1717948189352.png

Thanks,

 

 

 

0 Likes
Reply
Accepted solutions (1)
994 Views
13 Replies
Replies (13)

ed57gmc
Mentor
Mentor

Before learning how to do this programmatically, you need to learn how to do it manually. I will move this to the acade forum for you to find out how.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes

rhesusminus
Mentor
Mentor

There's a naming convention for the blocks also:
https://help.autodesk.com/view/ACAD_E/2023/ENU/?guid=GUID-426D2FCD-D82A-4FB7-A657-28D8B2EC336D


Trond Hasse Lie
EPLAN Expert and ex-AutoCAD Electrical user.
Ctrl Alt El
Please select "Accept Solution" if this post answers your question. 'Likes' won't hurt either. 😉
0 Likes

TXACDE24
Contributor
Contributor

I do know how to create AutoCAD Electrical symbols manually and how to create AutoCAD blocks programmatically.

The question is what specific attribute definitions or attribute references we need to add to the AutoCAD blocks in the program to make the block work as AutoCAD Electrical symbols.

E.g. the attributes I highlighted in the starting post.

0 Likes

pendean
Community Legend
Community Legend

@TXACDE24 wrote:

I do know how to create AutoCAD Electrical symbols manually and how to create AutoCAD blocks programmatically.

The question is what specific attribute definitions or attribute references we need to add to the AutoCAD blocks in the program to make the block work as AutoCAD Electrical symbols.

E.g. the attributes I highlighted in the starting post.


Like what please? your posts to date are not specific, too generic.

A sample DWG with one or more of your blocks in it with an explanation inside that file how you wish to use it in detail might help others help you 'specifically'.

 

TIA

0 Likes

rhesusminus
Mentor
Mentor

The help files happens to mention what attributes that are needed, and what they're supposed to be named also:

AutoCAD Electrical 2023 Help | About Schematic Attributes | Autodesk


Trond Hasse Lie
EPLAN Expert and ex-AutoCAD Electrical user.
Ctrl Alt El
Please select "Accept Solution" if this post answers your question. 'Likes' won't hurt either. 😉

rbh2024
Enthusiast
Enthusiast

Thank you for this link to the help file I have been looking for this as well!!!

0 Likes

TXACDE24
Contributor
Contributor

Like the Wire Connection attributes (TERM01 and TERM02). I created TERM01/TERM02 and X4TERM01/X1TERM02 block references, but they still are regular attributes instead of real "Wire Connections" when placed in AutoCAD Electrical drawings.

TXACDE24_0-1720338089421.png

 

 

0 Likes

arshdeepsingh404
Enthusiast
Enthusiast

Hi @TXACDE24 

 

I wrote a similar program a while ago that does symbol building but much faster than the symbol builder. One click place all required attributes at auto calculated positions.

https://www.linkedin.com/posts/arshdeep-singh-c-tech_autocad-autolisp-autocadelectrical-activity-720...

 

I used the standard entmake to create all the attributes and as long as the symbol is saved using the correct naming convention, the symbol works like any other ACE symbol.

 

    (entmake                                                                  ; Create a new entity in the drawing 
      (list 
        (cons 0 "ATTDEF")                                                     ; Entity type:                Attribute Definition
        (cons 1 AttributeDefaultValue)                                        ; Default value:              EmTopManualPTY String
        (cons 2 (nth index AttributesList))                                   ; Tag string:                 From List
        (cons 3 "")                                                           ; Prompt string:              EmTopManualPTY String
        (cons 8 "0")                                                          ; Layer name:                 Layer 0
        (cons 10 '(0.0 0.0 0.0))                                              ; Insertion point:            0,0,0
        (cons 11 (list xCoord yCoord zCoord))                                 ; Insertion point:            User Specified
        (cons 70 AttributeVisibility)                                         ; Attribute flags:            0 (Visible) 1 (Invisible)
        (cons 72 1)                                                           ; Horizontal Justification:   1 (Center)
        (cons 74 0)                                                           ; Vertical Justification:     0 (Not Specified)
        (cons 40 (atof AttributesHeight))                                     ; Text height:                User Specified
      )
    )
    
    (terpri)                                                                  ; Command Line Carriage Return
    (princ (strcat "Attribute Inserted: " (nth index AttributesList)))        ; Print Attribute Inserted: Name to Command Line
    (terpri) 

 

 

With regards to making the wire connections manually, You seems to be doing it correctly.

I inserted the attributes in a regular drawing with standard ATTDEF command and and created a BLOCK (without symbol builder as you would do with a program) and AutoCAD seems to recognize it no problem.

 

arshdeepsingh404_0-1720408071433.png

arshdeepsingh404_1-1720408079442.png

 

One of the most common problem that many users runs into is that forget to purge the drawing before trying out a new instance of the same Block. Make sure you are purging the block or trying it on an fresh new drawing.

 

Second thing to verify would be the Symbol naming convention.

https://help.autodesk.com/view/ACAD_E/2022/ENU/?guid=GUID-426D2FCD-D82A-4FB7-A657-28D8B2EC336D

 

And the last thing is to be mindful about the XTERM attributes which is where the wire connections are made (the green x shown while running wire command). Make sure everything is on layer "0" as well.


For Left Connections: TERMxx and X4TERMxx attribute

For Right Connections: TERMxx and X1TERMxx attribute

For Top Connections: TERMxx and X2TERMxx attribute

For Bottom Connections: TERMxx and X8TERMxx attribute

 

 

 

Regards,

Arshdeep Singh, C.Tech, CMSE®
Electrical Designer & Programmer
LinkedIn
www.blackcontrols.com

Please mark as "Accept Solution" if this resolved your issue. It might help someone else with the same question. Likes are welcome!
0 Likes

TXACDE24
Contributor
Contributor

Thanks for your input, Arshdeep!

I still cannot use the symbol I created in AutoCAD Electrical with wire connection features, etc.

I noticed that the symbol created by my program shows as block reference when I click on it (top screenshot), but a symbol created by Symbol Builder shows individual elements (arc, attribute definition etc.) (bottom screenshot).

Any ideas why?

TXACDE24_0-1720883707410.png

TXACDE24_1-1720883712163.png

 

 

0 Likes

rhesusminus
Mentor
Mentor

It seems like you do something wrong in your code, and place your block inside another block.


Trond Hasse Lie
EPLAN Expert and ex-AutoCAD Electrical user.
Ctrl Alt El
Please select "Accept Solution" if this post answers your question. 'Likes' won't hurt either. 😉

arshdeepsingh404
Enthusiast
Enthusiast
Accepted solution

Interesting! 

 

Few things that I see that you might not be doing right from your screenshot are:

 

Symbol Name is not quite right, I see you named it VCB01

First Character = V = Correct for Vertical Symbols

Second, Third Character = CB = Correct for family code of Circuit Breakers

Fourth Character = 0 = This should be either 1 or 2, In you case it should be 1 for parent symbol

Fifth Character = 1 = This shouldn't exist for Circuit Breakers, The fifth Character is to denote NO NC Contacts for symbols like relays.

 

XxTERMxx attributes are quite right either. I see you used X4TERM01 attribute twice.

1. Symbol Builder will usually complain about duplicated attributes.

2. X4TERM01 is for left connections, so you current block has two left connections

3. You have defined it as VCB i.e. Vertical Circuit Breaker, The valid connection points for this would be TOP and BOTTOM wire connections i.e. TERM01 and X2TERM01 for Top Wire Connection, TERM02 and X8TERM02 for Bottom Wire Connection.

 

For Left Connections: TERMxx and X4TERMxx attribute

For Right Connections: TERMxx and X1TERMxx attribute

For Top Connections: TERMxx and X2TERMxx attribute

For Bottom Connections: TERMxx and X8TERMxx attribute

Replace xx with instance, like TERM01 and X4TERM01, TERM02 and X1TERM02

 

These attributes are very important to be correct for wire connections to work. The insertion point of these attributes is where the little green x markers would appear for wire connection when using the block.

 

 

Regarding programming, I think @rhesusminus  has a very valid point about placing blocks inside a block. That might throw things off.

What is the workflow of your code? What does the code do after it has successfully placed all the attributes? Are you using a BLOCK command or WBLOCK or none and save everything as an independent .dwg

 

When we talk about the AutoCAD Electrical blocks at entity level, They are just geometry and attributes in a .dwg file, you don't use a block command to convert everything into a block. It is more like WBLOCK command where you extract all the geometry and attributes into an external .dwg file which when opened, appears in as an exploded block would.

 

 BLOCKWBLOCK
PurposeCreates a block definition within the current drawingWrites a block to a separate drawing file (DWG)
ScopeLocal to the drawingCan be used in any drawing
StorageStored in the current drawing fileSaved as an external DWG file
Usage ContextInternal reuse within the same drawingExternal reuse and sharing across multiple drawings

 

 

In order for more effective troubleshooting, lets break things down. See the attached dwg file, I created that using ATTDEF commands for attributes and placed a regular rectangle. I didn't use any BLOCK or WBLOCK commands, Just simply a new drawing with nothing to purge, Add Rectangle, Add Attributes, and save as HCB1

 

When I insert this in AutoCAD Electrical drawing, It comes an any electrical symbol would. And what I mean by inserting is to Click on Icon Menu > Browse > Select the HCB1 dwg file.

 

arshdeepsingh404_2-1720916172173.png

 

arshdeepsingh404_1-1720916134665.png

 

arshdeepsingh404_0-1720916127640.png

 

Try the attached symbol, and try creating a similar symbol using ATTDEF without any coding to narrow down the problem. If the both of these work, then we can confidently say that your code is doing something different that doesn't or only partially works.

 

Try a little simpler version of your code, only pieces at a time.

1. Try a code that creates a rectangle and inserts the basic attributes like TAG1, MFG, CAT, DESC1, DESC2.

2. Add additional attributes for wire connections, Set of TERMxx and XxTERMxx for connections.

3. If still no success, please share your code or a sample block created by your code and I can look at it.

 

Happy Coding!

Regards,

Arshdeep Singh, C.Tech, CMSE®
Electrical Designer & Programmer
LinkedIn
www.blackcontrols.com

Please mark as "Accept Solution" if this resolved your issue. It might help someone else with the same question. Likes are welcome!
0 Likes

TXACDE24
Contributor
Contributor

Now it works!

I added all shapes and attributes in a block and then save the block to a dwg file. I think that was what caused the issues.

The symbol works as needed when I remove the block and add all new entities directly in the dwg file.

Thank you so much!

arshdeepsingh404
Enthusiast
Enthusiast

You're Welcome! That's great to hear its working now.

 

Happy coding!

 

Regards,

Arshdeep Singh, C.Tech, CMSE®
Electrical Designer & Programmer
LinkedIn
www.blackcontrols.com

Please mark as "Accept Solution" if this resolved your issue. It might help someone else with the same question. Likes are welcome!
0 Likes