Difference between revisions of "Cells"

From Microstation VBA Wiki
Jump to: navigation, search
(Created page with '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. <PRE> Dim oCell a…')
 
Line 13: Line 13:
 
ptScale = ActiveSettings.Scale
 
ptScale = ActiveSettings.Scale
 
oMatrix = Matrix3dIdentity
 
oMatrix = Matrix3dIdentity
 +
</PRE>
 +
 +
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:
 +
 +
<PRE>
 +
Set oCell = CreateCellElement2("AR34", ptStart, ptScale, False, oMatrix)
 +
ActiveModelReference.AddElement oCell
 +
</PRE>
 +
 +
<PRE>
 +
oMatrix = Matrix3dFromAxisAndRotationAngle(2, Radians(180))
 
</PRE>
 
</PRE>

Revision as of 13:32, 5 August 2010

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
oMatrix = Matrix3dFromAxisAndRotationAngle(2, Radians(180))