I try make more than one SketchBlockDefinition from one file. But with repeated use MakeSketchBlockFromFile with same path, it return nothing (VB .NET, SolidWorks 2014 SP3).
How I can copy SketchBlockDefinition?
Based on this summary, I don't see any direct methods. This isn't all of the available methods for sketchblockdefinitions but I think it would include copy methods if they existed.
2012 SOLIDWORKS API Help - Block Definitions and Block Instances
I can think of two indirect approaches:
Explode the block and then generate a new one from its sketch entities.
2012 SOLIDWORKS API Help - ExplodeSketchBlockInstance Method (ISketchManager)
2012 SOLIDWORKS API Help - MakeSketchBlockFromSelected Method (ISketchManager)
Save the sketch block definition to a new temp file (as a copy) and then import a new sketch block definition from the temp file.
2012 SOLIDWORKS API Help - Save Method (ISketchBlockDefinition)
2012 SOLIDWORKS API Help - MakeSketchBlockFromFile Method (ISketchManager)
You don't need to create more than one SketchBlockDefinition.
Once you have created one, you can use that to create any number of SketchBlockInstances.
So, I use SketchMgr.GetSketchBlockDefinitions to check if the block that I want to create already has a SketchBlockDefinition created.
If not, I use SketchMgr.MakeSketchBlockFromFile
Otherwise I use SketchMgr.InsertSketchBlockInstance
Thanks for the answer, but I need more than one SketchBlockDefinition. Once I add definition I change its width. If I get instance and change width in this case, the width will be changed in all instances of definition.
If I get copy of instance and change width in this case, the width will be changed only in this definition and its instances. This is what I need.
One frustrating thing about SketchBlockDefinitions is that you can't just import them on their own. You have to insert a SketchBlockInstance during the operation that loads it.
I frustrating about SketchBlockDefinition and import too.
So, I select variant with explode the block.
Thanks for your help.
Retrieving data ...