Cells

From Microstation VBA Wiki
Jump to: navigation, search

Placing a cells is similar to placing lines in that both are elements. First you store the cell into a variable then you put that variable into the drawing.

Dim oCell as CellElement

It makes sense that you would need a point defined just like when your draw a line. But you also have to have a special kind of point called a scaling point and because you can bring a cell in at an angle, you also need a Rotation Matrix. If you want to keep it simple and bring the cell in at a scale of one with no rotation you can set up a point variable and a matrix and then set them to some standard values like this:

Dim ptScale As Point3d
Dim oMatrix As Matrix3d

ptScale = ActiveSettings.Scale
oMatrix = Matrix3dIdentity

Now you are ready to place a cell. Assuming the correct cell library is attached (should probably check first), you should be able to store a cell (in this example a cell named "AR34") in the oCell cell element you dimensioned earlier, and then add it to the drawing:

Set oCell = CreateCellElement2("AR34", ptStart, ptScale, False, oMatrix)
ActiveModelReference.AddElement oCell

To rotate the cell when it is placed, use a Rotation Matrix