Smart Block to regular block

Smart Block to regular block

Ken.castillo
Contributor Contributor
2,231 Views
9 Replies
Message 1 of 10

Smart Block to regular block

Ken.castillo
Contributor
Contributor

As we are migrating to AutoCAD Electric one of our clients has an Issue. I know that Special Explode will convert all to lines etc.  Our client wishes for the blocks to remain however just not electrical.  Blocks with attributes, just not intelligence. 

0 Likes
Accepted solutions (1)
2,232 Views
9 Replies
Replies (9)
Message 2 of 10

Anonymous
Not applicable

Blocks with attributes are intelligent. Not sure what you are wanting here.

0 Likes
Message 3 of 10

Ken.castillo
Contributor
Contributor

can Electrical drawing can be opened in regular autocad?

0 Likes
Message 4 of 10

Anonymous
Not applicable
Accepted solution
0 Likes
Message 5 of 10

jseefdrumr
Mentor
Mentor
Well, it's the attributes that make the blocks intelligent, so this probably isn't possible.

Or, more accurately, it's the attributes in the blocks that allow ACADE to execute its commands. The intelligence is actually in the command structure, but we still often refer to the blocks as if they are what's 'smart'. Put those blocks in any other software and they're as dumb as a box of rocks. But, the same can be said for a block in this software, if it doesn't have any (or the correct) attributes.

If you take out the attributes of an ACADE block, you're also removing all of its annotation. Cross references, tags, pin numbers, etc are all held in attributes.

That being said:

If your clients aren't running ACADE, then they won't be able to use the attributes anyway - so might as well leave them in.

And if your clients ARE using ACADE, then taking the attributes out of the blocks would totally undermine the software's ability to use them. Essentially, you'd be breaking the blocks so that they no longer work. Which means you wouldn't be able to do anything with them either, for instance if the client wanted the drawings edited in the future.

If they're adamant that you supply them with drawings where the blocks aren't intelligent, but are still blocks, then I suppose you could use Special Explode to remove the unused attributes, and then re-block each symbol with a new name. The amount of CAD time this would take could very quickly cost the client more than what it did to create the drawings to begin with.

It should be noted that any block built specifically for use within ACADE should function just fine in non-Electrical AutoCAD software. Meaning, you can take any one of ACADE's symbols into Mechanical, or regular vanilla ACAD, and use them as a block. You won't need a proxy handler or anything like that.


Jim Seefeldt
Electrical Engineering Technician


0 Likes
Message 6 of 10

Ken.castillo
Contributor
Contributor

Yes I agree, however when working with GLOBAL mega oil and gas corps that have drawings that are over 60 years old, they are very reluctant to change. Unfortunately it is mostly the US based companies that are like that.

0 Likes
Message 7 of 10

Anonymous
Not applicable

Technically I guess you could open the blocks in block editor and rename all the attributes. That way it would technically meet the criteria, in that the block would still have attributes but it would not be intelligent in the sense that ACADE would not know what to do with the attribute data. Though why they would want this is beyond me.

 

Also doing this to every single block is not going to be fun.

 

As Jim alluded to ACADE produces 100% standard AutoCAD DWG drawings. You can open these in AutoCAD, AutoCAD LT, etc. You could, for example, open an ACADE block in the AutoCAD LT attribute editor and see it has an attribute called 'ASSYCODE' and its value is 'xyz' like any other kind of attribute. The difference between ACADE and AutoCAD vanilla is ACADE knows to look up its database for parts with corresponding 'ASSEMBLYLIST' values whereas AutoCAD will just treat it as any other attribute.

 

You could even edit attribute values, move blocks, redraw lines etc. in regular AutoCAD but it is very likely to cause project issues if that drawing is later used again in ACADE.

0 Likes
Message 8 of 10

rhesusminus
Mentor
Mentor

Just for fun, I made a little VBA macro, that stupidifies the drawings. It renames all layers/blocks/attributes.

Option Explicit

Public Sub Stupidify()

    
    ' Rename layers (Except 0 and defpoints)
    Dim Layer As AcadLayer
    Dim BlockRef As AcadBlockReference
    Dim Block As AcadBlock
    Dim AttRef As AcadAttributeReference
    Dim Att As AcadAttribute
    Dim Ent As AcadEntity
    Dim Counter As Integer
    Dim Prefix As String
    Dim NewName As String
    Counter = 0
    Prefix = "LAYER_"
    NewName = Prefix & CStr(Format(Counter, "0000"))
    For Each Layer In ActiveDocument.Layers
        If Layer.Name <> "0" And StrComp(Layer.Name, "defpoints", vbTextCompare) <> 0 Then
            While DoesLayerExist(NewName)
                Counter = Counter + 1
                NewName = Prefix & CStr(Format(Counter, "0000"))
            Wend
            Layer.Name = NewName
        End If
    Next
    
    
    Counter = 0
    Prefix = "BLOCK_"
    NewName = Prefix & CStr(Format(Counter, "0000"))
    
    For Each Block In ActiveDocument.Blocks
        
        If Left(Block.Name, 1) <> "*" Then
             While DoesBlockExist(NewName)
                Counter = Counter + 1
                NewName = Prefix & CStr(Format(Counter, "0000"))
            Wend
            Block.Name = NewName
        End If
        
        Dim AttCounter As Integer
        Dim AttPrefix As String
        Dim AttNewName As String
        AttCounter = 0
        AttPrefix = "ATT_"
        AttNewName = AttPrefix & CStr(Format(AttCounter, "0000"))
        
        For Each Ent In Block
            
            If TypeOf Ent Is IAcadAttribute Then
                Set Att = Ent
                While DoesAttributeExist(AttNewName, Block)
                    AttCounter = AttCounter + 1
                    AttNewName = AttPrefix & CStr(Format(AttCounter, "0000"))
                Wend
                Att.TagString = AttNewName
            End If
            
        Next
    Next
    
    Dim ss As AcadSelectionSet
    Dim DxfCode(0) As Integer
    Dim DxfData(0) As Variant
    
    DxfCode(0) = 0
    DxfData(0) = "INSERT"
    Set ss = ActiveDocument.SelectionSets.Add("BLOCKS")
    ss.Select acSelectionSetAll, , , DxfCode, DxfData
    
    For Each BlockRef In ss
        Counter = 0
        Prefix = "ATT_"
        NewName = Prefix & CStr(Format(Counter, "0000"))
        Dim Atts As Variant
        Dim AttCnt As Integer

        If BlockRef.HasAttributes Then
            Atts = BlockRef.GetAttributes
            For AttCnt = LBound(Atts) To UBound(Atts)
                Set AttRef = Atts(AttCnt)
                While DoesAttributeReferenceExist(NewName, BlockRef)
                    Counter = Counter + 1
                    NewName = Prefix & CStr(Format(Counter, "0000"))
                Wend
                
                AttRef.TagString = NewName
            Next
        End If
        
    Next

End Sub

Private Function DoesLayerExist(ByVal LayerName As String) As Boolean
    
    Dim Layer As AcadLayer
    
    For Each Layer In ActiveDocument.Layers
        If StrComp(Layer.Name, LayerName, vbTextCompare) = 0 Then
            DoesLayerExist = True
            Exit Function
        End If
    Next
    
    DoesLayerExist = False
    
End Function

Private Function DoesBlockExist(ByVal BlockName As String) As Boolean
    
    Dim Block As AcadBlock
    
    For Each Block In ActiveDocument.Blocks
        If StrComp(Block.Name, BlockName, vbTextCompare) = 0 Then
            DoesBlockExist = True
            Exit Function
        End If
    Next
    
    DoesBlockExist = False
    
End Function

Private Function DoesAttributeExist(ByVal AttName As String, Block As AcadBlock) As Boolean
    
    Dim Att As AcadAttribute
    Dim Ent As AcadEntity
    
    For Each Ent In Block
        If TypeOf Ent Is AcadAttribute Then
            Set Att = Ent
            If StrComp(Att.TagString, AttName, vbTextCompare) = 0 Then
                DoesAttributeExist = True
                Exit Function
            End If
        End If
    Next
    
    DoesAttributeExist = False
    
End Function

Private Function DoesAttributeReferenceExist(ByVal AttName As String, Block As AcadBlockReference) As Boolean
    
    Dim Att As AcadAttributeReference
    Dim Atts As Variant
    Dim AttCnt As Integer
    
    If Block.HasAttributes Then
        Atts = Block.GetAttributes
        For AttCnt = LBound(Atts) To UBound(Atts)
            Set Att = Atts(AttCnt)
            If StrComp(Att.TagString, AttName) = 0 Then
                DoesAttributeReferenceExist = True
                Exit Function
            End If
        Next
    End If

    DoesAttributeReferenceExist = False
    
End Function

Can be run in a script to apply to many drawings.

See attached drawing for example.


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

SeedyNotions
Advocate
Advocate

@rhesusminus Any advice on how to use this in a script? I have some work I need to send to a competitor and we don't want to lose any IP. Many thanks in advance.

0 Likes
Message 10 of 10

rhesusminus
Mentor
Mentor

-VBARUN

Filename.dvb!modulename.macroname

 

 

This works in a script.


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