AnsweredAssumed Answered

Insert a block

Question asked by Ali Al-Abbasi on Sep 4, 2017
Latest reply on Sep 4, 2017 by Ali Al-Abbasi

Hello Guys,

 

Good morning,

I need your help to fix this small issue.

I'm trying to insert a block into a sketch but the result is nothing.

 

What I did?

- I created a block using (MakeSktechBlockFromSelected) method. The block was created successfully on a plane (Plane2). Then, rename it.

- I created a new sketch on another plane (Plane1). I inserted the created block using (InsertSketchBlockInstance). But the result is nothing.

 

Code: Below a part of the code in VBA.

'Make a block

boolstatus = swModel.Extension.SelectByID2("Line4", "SKETCHSEGMENT", -0.011325044180845, 0.110278186438432, -9.89352204071668E-02, False, 0, Nothing, 0)

boolstatus = swModel.Extension.SelectByID2("Line3", "SKETCHSEGMENT", -0.131648020832848, 0.184732304174255, -5.30542615861535E-02, True, 0, Nothing, 0)

boolstatus = swModel.Extension.SelectByID2("Line2", "SKETCHSEGMENT", -0.185129099616164, 9.53873628912672E-02, 8.97572385943509E-02, True, 0, Nothing, 0)

boolstatus = swModel.Extension.SelectByID2("Line5", "SKETCHSEGMENT", -0.435036231750446, 0.254222814061024, 0.180854732689188, True, 0, Nothing, 0)

boolstatus = swModel.Extension.SelectByID2("Line6", "SKETCHSEGMENT", 0.32564800651241, -0.12383865044199, -0.201829481698532, True, 0, Nothing, 0)

 

Set myBlockDefinition = swModel.SketchManager.MakeSketchBlockFromSelected(Nothing)

boolstatus = swModel.Extension.SelectByID2("Block1-1", "SUBSKETCHINST", 0, 0, 0, False, 0, Nothing, 0)

boolstatus = swModel.SelectedFeatureProperties(0, 0, 0, 0, 0, 0, 0, 1, 0, "Base Block")

swModel.ClearSelection2 True

swModel.SketchManager.InsertSketch True

 

'Make a new sketch and insert a block

boolstatus = swModel.Extension.SelectByID2("Plane1", "PLANE", 0, 0, 0, False, 0, Nothing, 0)

swModel.SketchManager.InsertSketch True

Set myBlockInstance = swModel.SketchManager.InsertSketchBlockInstance(myBlockDefinition, Nothing, 1, 0)

boolstatus = swModel.Extension.SelectByID2("Block2-1", "SUBSKETCHINST", 0, 0, 0, False, 0, Nothing, 0)

boolstatus = swModel.SelectedFeatureProperties(0, 0, 0, 0, 0, 0, 0, 1, 0, "Base Block2")

swModel.ClearSelection2 True

 

The block definitions are already declared

 

Dim myBlockDefinition As SldWorks.SketchBlockDefinition

Dim myBlockInstance As SldWorks.SketchBlockInstance

 

 

Any comment?

Thanks

 

Ali

Outcomes