SW2007 API changes

Do you have code that uses Block or Symbol insertions?  If so, then this Blog is for you!

It seems that something has changed in the New SW2007 API.  We are working with SW to further understand what has changed.

In the past, we were able to simply insert Blocks fairly easy

swModel.EditSketch
Set BlockInstance1A = swModel.InsertBlock(“c:flat_coated.SLDBLK”, 0.0254, 0.0254, 0, 0#)

Here is a sample bit of code that seems to work fine now for Blocks:

Private Sub Command2_Click()
Dim swModel As SldWorks.ModelDoc2
Dim BlockFName1 As String

‘Attach to running instance of SolidWorks
If swApp Is Nothing Then Set swApp = GetObject(, “SldWorks.Application”)
Set swModel = swApp.ActiveDoc

Dim BlockInstance1A             As SldWorks.BlockInstance
Dim swSketchBlockDef            As SldWorks.SketchBlockDefinition
Dim swSketchMgr                 As SldWorks.SketchManager
Dim swMathUtil                  As SldWorks.MathUtility
Dim swMathPoint                 As SldWorks.MathPoint
Dim nPt(2)                      As Double
Dim vPt                         As Variant
Dim vInstPt                     As Variant
Set swSketchMgr = swModel.SketchManager
Set swMathUtil = swApp.GetMathUtility
‘Define insertion point
nPt(0) = 0.02
nPt(1) = 0.02
nPt(2) = 0#
vPt = nPt
Set swMathPoint = swMathUtil.CreatePoint(vPt)

Set swSketchBlockDef = swSketchMgr.MakeSketchBlockFromFile(swMathPoint, “c:flat_coated.SLDBLK”, False, 1, 0)
Set BlockInstance1A = swModel.SketchManager.InsertSketchBlockInstance(swSketchBlockDef, swMathPoint, 1, 0)
End Sub

—————————————————————————————————-

In an exisitng bit of code for symbols, I was doing:

BlockFName1 = “c:CHECK.SLDSYM”
swModel.InsertCustomSymbol BlockFName1

and all was working fine.  Now with SW2007 SP3, I can not get it to insert sybols at all and have been forced to switch everything to Blocks.

I hope you find this entry informative and it can help you avoid a couple of pit falls that I was not able to dodge!

Thanks,

Scott Evans

Please contact Inflow tehnology @ www.inflow-tech.com for more information

  • Share this
Find Your Design Solution in the CATI Store.
Browse Products