Tuesday, February 07, 2012
How to read block in a dft file without opening the dft file?
Last Post 20 Sep 2010 12:10 AM by Sanjay Kulkarni. 2 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
assassinUser is Offline
New Member
New Member
Posts:94

--
02 Sep 2010 09:02 AM  

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!

Sanjay KulkarniUser is Offline
New Member
New Member
Posts:31

--
19 Sep 2010 10:55 AM  

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)
   
    dftDoc2.Close
   
    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.

Sanjay Kulkarni
Sanjay KulkarniUser is Offline
New Member
New Member
Posts:31

--
20 Sep 2010 12:10 AM  

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

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

Sanjay Kulkarni
You are not authorized to post a reply.

Active Forums 4.2
Copyright © 2011 JasonNewell.NET