Has anyone got any ideas? Or can tell me it isnt possible?
If you can't find a setting to do it. Maybe you can work around it by looking for matching block names that can be deleted & inserted again.
Thanks for the suggestion. I want to try to avoid that approach but if I cant find any other way I think that is how I will have to handle it.
Appreciate your input.
I've not been able to find any API call for this.
Thanks for commenting. I don't have high hopes if you havent found anything. Have you got any other ideas which might keep the processing times down?
We often have drawing files with up to 40 sheets and searching through for 40 possible duplicate block names as suggested by Elmar seems it might take a long time to process.
Search your block instances is quick. They sit in the Blocks folder. I would see if I could relink any duplicate block instance to the first one and then delete all unused blocks.
Could you point me to some documentation for relinking duplicate block instances?
API help is a good start
Take a look at this example: #CODE|Make Sketch Block Instance Independent
' Preconditions: Part, assembly, or drawing document containing
' one or more block definitions
' and block instances is open.
' Postconditions: The angles of all block instances are modified.
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim skMgr As SldWorks.SketchManager
Dim pBlock As SldWorks.SketchBlockDefinition
Dim pInst As SldWorks.SketchBlockInstance
Dim leaderPt As SldWorks.MathPoint
Dim insPt As SldWorks.MathPoint
Dim vInstPt As Variant
Dim vInstances As Variant
Dim vBlocks As Variant
Dim nInstanceCount As Long
Dim itr As Long
Dim jtr As Long
Dim bLinkToFile As Boolean
Dim strInsPoint As String
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set skMgr = swModel.SketchManager
' To change the angles, you must edit the block's sketches
vBlocks = skMgr.GetSketchBlockDefinitions
' Exit if no blocks
If IsEmpty(vBlocks) Then
' Process block definitions
For itr = 0 To UBound(vBlocks)
Set pBlock = vBlocks(itr)
' Block defintion linked to file?
Debug.Print " Link To File = " & pBlock.LinkToFile
' Block linked file name
Debug.Print " Link File Name = " & pBlock.FileName
' Block definition insertion point
Set insPt = pBlock.InsertionPoint
vInstPt = insPt.ArrayData
strInsPoint = " Insertion point: x = " + CStr(vInstPt(0) * 1000) + " , y = " + CStr(vInstPt(1) * 1000) + " , z = " + CStr(vInstPt(2) * 1000)
' Number of block instances of this block definition
nInstanceCount = pBlock.GetInstanceCount
Debug.Print " Instance Count = " & nInstanceCount
' Process block instances
If nInstanceCount > 0 Then
vInstances = pBlock.GetInstances
For jtr = 0 To UBound(vInstances)
Set pInst = vInstances(jtr)
' Block instance position
Set insPt = pInst.InstancePosition
vInstPt = insPt.ArrayData
strInsPoint = " Instance position: x = " + CStr(vInstPt(0) * 1000) + " , y = " + CStr(vInstPt(1) * 1000) + " , z = " + CStr(vInstPt(2) * 1000)
' Get block instance angle
Debug.Print " Original angle = " & pInst.Angle
' Change block instance angle
pInst.Angle = 90 / 57.3
Debug.Print " Modified angle = " & pInst.Angle
' Block instance scale
Debug.Print " Scale = " & pInst.Scale
' Block instance owner's sketch name
Debug.Print " Owner Sketch = " & pInst.GetSketch.Name
Much appreciated I'll see what I can piece together and report back if I have any success.