I am having difficulty figuring out how to "Remove" ablockfrom a drawing with the new API changes. With SW2006,this isa portion of the code I used to locate a block, not byname, but bycoordinates, remove it, and add a new one.
Set SelMgr = Part.SelectionManager
Part.SelectByID "", "BLOCKINST", 10.75 *0.0254, 0.25 *0.0254, 0
Part.SelectByID "", "BLOCKINST", 8.15 * 0.0254,0.21 * 0.0254,0
Part.SelectByID "", "BLOCKINST", 16.75 *0.0254, 0.25 *0.0254, 0
Part.SelectByID "", "BLOCKINST", 21.75 *0.0254, 0.25 *0.0254, 0
Part.SelectByID "", "BLOCKINST", 33.75 *0.0254, 0.25 *0.0254, 0
Set BlkInstance = SelMgr.GetSelectedObject3(1)
Retval = Part.DeleteSelection(False)
Part.ClearSelection
' insert new logo at set x and y locations from above
Set NewBlkInstance = Part.InsertBlock(BlockFile, XBlock,YBlock, 0,1)
I have tried using this:
boolstatus = Model.Extension.SelectByID2("","BLOCKDEF",XBlock, YBlock, 0, False, 0, Nothing,swSelectOptionDefault)
Not sure if "BLOCKDEF" is what I should be using ornot.
Can someone please help???
SolidworksApi macros







Set SelMgr = Part.SelectionManager
Part.SelectByID "", "BLOCKINST", 10.75 *0.0254, 0.25 *0.0254, 0
Part.SelectByID "", "BLOCKINST", 8.15 * 0.0254,0.21 * 0.0254,0
Part.SelectByID "", "BLOCKINST", 16.75 *0.0254, 0.25 *0.0254, 0
Part.SelectByID "", "BLOCKINST", 21.75 *0.0254, 0.25 *0.0254, 0
Part.SelectByID "", "BLOCKINST", 33.75 *0.0254, 0.25 *0.0254, 0
Set BlkInstance = SelMgr.GetSelectedObject3(1)
Retval = Part.DeleteSelection(False)
Part.ClearSelection
' insert new logo at set x and y locations from above
Set NewBlkInstance = Part.InsertBlock(BlockFile, XBlock,YBlock, 0,1)
I have tried using this:
boolstatus = Model.Extension.SelectByID2("","BLOCKDEF",XBlock, YBlock, 0, False, 0, Nothing,swSelectOptionDefault)
Not sure if "BLOCKDEF" is what I should be using ornot.
Can someone please help???
SolidworksApi macros
