How to read block in a dft file without opening the dft file?

[ Edited ]


Dear all, I want to use the block which is contained in a draft file. And I won't open the draft file. Just like user drag a block from block library to a draft file in interactive environment. Any program language is OK! Thanks!


Posted by: assassin 007
Post date: 9/2/2010 4:02:06 AM


RE: How to read block in a dft file without opening the dft file?

[ Edited ]


First some background:

Blocks in Solid Edge work very similar to AutoCAD blocks. There is a block (block definition in AutoCAD) and then there is a BlockReference. BlockReference can be called as an instance of the block. So, while blocks are stored in draft document object, block references are stored in individual sheets. Just a note if you are not aware - a block can exist in a draft document without being referenced but a BlockReference can't, without a block.

When we manually insert a block from one drawing into another we are actually implement the following procedure:

1. Open the drawing that contains the block.

2. Load the block into the current draft document.

3. Create a reference to that block in the current sheet (by dragging it).

Most of the steps are transparent to the user.


When we want to program this activity, we must remember that since the block is a geometric object, we can not access it without opening the file that contains that block. So it is not possible to copy block from one draft to another draft without opening both the draft files.

Having said this, you can programmatically hide the draft file containing the block and copy the required block into current draft file.

Here is some quick-n-dirty code (SE 20 - VB6) that copies existing block into active sheet. It assumes that a draft file is open and you know the path of the draft file that contains the block ("c:\SEblocks\MyBlocks.dft"), the name of the block ("myBlock1") and the insertion point (5,5) . The scale and rotation are optional.

(I have ommitted routine statements and delarations to keep the code short).


Option Explicit


Sub main()

'''' Blocks in draft file

    Set dftDoc = seApp.ActiveDocument


    Set dftDoc2 = seApp.Documents.Open("c:\SEblocks\MyBlocks.dft")


    dftDoc2.Windows(1).Visible = False


    Set blk = dftDoc2.Blocks("MyBlock1")


    Set curBlk = dftDoc.Blocks.CopyBlock(blk)




    Set sht = dftDoc.ActiveSheet


    sht.BlockOccurrences.Add curBlk.Name, 5, 5

''' SE block is exactly similar to acad block.


End Sub

It is interesting to note that the actual syntax of CopyBlock method is different from that mentioned in the help file.

This could be extended to a scenario where you can copy block from one file to another file without visisbly opening SolidEdge atall.

Post here if you need more information / clarifications.

Be aware that this is the result of my exploration. So there might be a better alternative solution.


Posted by: Sanjay Kulkarni
Post date: 9/19/2010 5:55:12 AM

RE: How to read block in a dft file without opening the dft file?

[ Edited ]


1. The correct word is BlockOccurrence and not BlockReference. (Too much influence of AutoCAD Smiley Happy)

2. The following statement:

sht.BlockOccurrences.Add curBlk.Name, 5, 5

should be replaced with

sht.BlockOccurrences.Add curBlk.Name, 5.0./ 1000, 5.0 / 1000


Posted by: Sanjay Kulkarni
Post date: 9/19/2010 7:10:45 PM