How to insert a Block Occurrence

PLM World Member Genius PLM World Member Genius
PLM World Member Genius

Does anyone have some sample code showing how to insert a block occurrence into a draft file?  This includes positioning the block and setting its scale.

 

Thanks.

1 REPLY

Re: How to insert a Block Occurrence

PLM World Member Genius PLM World Member Genius
PLM World Member Genius

Ok. I got it.  It comes down to understanding the difference between a block and a block occurrence.  Basically, you add a block to a new drawing by using the CopyBlock command on a block from a different drawing.  Then you Add an occurrence of that block to the sheet that you want.

 

 objDocBlocks = objApp.Documents.Open("C:\existing_blocks.dft")
Dim objBlocks As SolidEdgeDraft.Blocks = objDocBlocks.Blocks
Dim objBlock0 As SolidEdgeDraft.Block = objBlocks.Item(0)

objDocNew = objApp.Documents.Open("C:\temp\new_blocks.dft")
Dim objBlocksNew As SolidEdgeDraft.Blocks = objDocNew.Blocks
Dim objBlockNew0 As SolidEdgeDraft.Block = objBlocksNew.CopyBlock(objBlock0)

Dim objSheet1 As SolidEdgeDraft.Sheet = objDocNew.ActiveSheet
Dim objBlockOccurencesNew As SolidEdgeDraft.BlockOccurrences = objSheet1.BlockOccurrences

objBlockOccurencesNew.Add(objBlockNew0.Name, 0.05, 0.01, Scale:=0.00125)