ds-blue-logo
Preview  |  SOLIDWORKS USER FORUM
Use your SOLIDWORKS ID or 3DEXPERIENCE ID to log in.
BBBart Bolscher25/02/2014

In our company we are using more and more blocks for our hydraulic schemes. We need to build these drawings for our machines. Normally whe "drag and drop" our block into the drawing. A lot of times these blocks needs to be rotated (90, 180 or 270 degrees). I want to make an button which will rotate these blocks 90 degrees (counter)clockwise.

What I would like to have is the next sequence:

  1. The user selects a block in the Drawing.
  2. The user click on the button "rotate block 90 degrees clockwise" (Or the button "rotate block 90 degrees counterclockwise").
  3. The macro will make sure that the block is able to rotate (Uncheck the "Lock angle" checkbox. See image "select and rotate motor.jpg").
  4. The macro will rotate the block 90 degrees (counter)clockwise.

I already have a little peace of code. At this moment it doesn't always work. Also at this moment it will only rotate a predefined block (motor). If I select an other block, like block "filter", it should only rotate block "filter". Also the selected block should rotate around it's own centerpoint (or insertpoint).

Dim swApp As Object

Dim Part As Object

Dim boolstatus As Boolean

Dim longstatus As Long, longwarnings As Long

Sub main()

Set swApp = _

Application.SldWorks

Set Part = swApp.ActiveDoc

boolstatus = Part.Extension.SelectByID2("motor", "SKETCHSEGMENT", 0.2521909783982, 0.1883344360771, 0, False, 0, Nothing, 0)

Part.Extension.RotateOrCopy False, 1, False, 0.1497784295293, 0.1809095839578, 0, 0, 0, 1, 0.1883344360771

End Sub

Thank in advance.