Cancel
Showing results for 
Search instead for 
Did you mean: 

Copy a block from a "Template" drawing without opening that drawing

Creator
Creator

Hi All,

 

We use a "Template" drawing located in our library folder were we can find our "Template" drawing blocks:

1. Click on the drawing

2. Click & Drag the block you want to import to your drawing

2019-01-14 22_37_03-Solid Edge 2019 - Draft - [5252-0009.dft][Read-Only].png

This is a fairly userfriendly method to import blocks to your drawing without having to open the drawing which contains the original blocks.

 

My Question: Is this method of importing blocks without having to open the original draft also possible using VB.net?

I want to import all template blocks to a drawing. 

 

Currently I am using this method but this isn't really a feasible solution because SE opens and closes the draft which takes a lot of time:

dim objBlockDraft as SolidEdgeDraft.DraftDocument
objBlockDraft = objApp.Documents.Open([File Path of template blocks drawing])
For i = 1 To objBlockDraft.Blocks.Count objBlock = objDraft.Blocks.CopyBlock(objBlockDraft.Blocks.Item(i)) Next

objBlockDraft.Close()

This code was derived from this topic: https://community.plm.automation.siemens.com/t5/Solid-Edge-Developer-Forum/How-to-insert-a-Block-Occ...

 

Seeing that it is possible to import blocks without opening a drawing while using the UI, I can't help but wonder if this could also be possible using the SE API.

 

Thank you in advance for your help and input!

 

 

3 REPLIES 3

Re: Copy a block from a "Template" drawing without opening that drawing

Solution Partner Genius Solution Partner Genius
Solution Partner Genius

The "template" must always be opened, but you can do that in a silent way (same thing that SE does) with this option in Documents.Open:

 

objBlockDraft = objApp.Documents.Open([File Path of template blocks drawing],8)

 

Julian Guillo
Pixel Sistemas SL
Spain

Re: Copy a block from a "Template" drawing without opening that drawing

Creator
Creator

It seems to work a bit faster indeed!

 

I changed my macro so it will only copy / "Import" those blocks if necessary. 

 

Thank you!

Re: Copy a block from a "Template" drawing without opening that drawing

Solution Partner Valued Contributor Solution Partner Valued Contributor
Solution Partner Valued Contributor

Hi,

 

You can also try this method :

objDraft.Blocks.AddBlockByFile([File Path of template blocks drawing])

Romuald BERTIN