Drafting, how to replace title block.

PLM World Member Creator PLM World Member Creator
PLM World Member Creator

I have back ground sheets of all different sized title blocks.  I created all of them to include a common block, so I could update them all quickly.  I can copy a new block into a draft with api, and I can replace a block occurance by hand, but I can't find a way to replace the block with a changed block using api.  Has anyone had a similar need?

4 REPLIES

Re: Drafting, how to replace title block.

Legend
Legend

Hi Kahaen.

 

I have a macro that changes one block occurrence by another different block occurrence.

 

I use it to change surface finishing symbols.

 

Once you have copied the modified block to the draft file you have to:

 

Delete the old occurrences (objsheet is the sheet where you have the block occurence): 

Try
    For Each blockitem In objSheet.BlockOccurrences
        Dim blockname As String = blockitem.Block.Name
        If blockname = "your block name" Then
blockitem.GetOrigin(X, Y) ' To get the origin of the occurrence blockitem.delete() End If Next Catch ex As Exception End Try

 

Add the new ones in the desired position (here we insert the new block in the same position where the old block was).

 

newblock = objDraftDoc.Blocks.Item("your modified block")
objSheet.BlockOccurrences.Add(newblock.Name, X, Y)

 

Hope it heps.

 

Best regards,

Héctor Pelayo Izquierdo
Engineering Department, JAE Ingeniería y Desarrollos, S.L.
Solid Edge ST9 MP5 | NX 9
Development: VB.NET

Re: Drafting, how to replace title block.

PLM World Member Creator PLM World Member Creator
PLM World Member Creator

I was hoping to not need to delete and place a differeny block, but that seems to be the only option for now.  I have submitted a PR for the ability to replace with API, since the ability is there with the GUI.

 

Thanks for your help!

Re: Drafting, how to replace title block.

Pioneer
Pioneer

Hello

I try to replace a dft block from another dft with Visual-Basic.

Anybody has a piece of code to do it?

Thanks

PhilSmiley Happy

Re: Drafting, how to replace title block.

Pioneer
Pioneer

Question,

 

the block that is being deleted is clear ... but if the new block isn't in the drafting where from will it be added and how does the macro know that ?