Python

Get Line Vertices

Q How do I create an offset copy of a DGN line element? This question arose on the Be Communities MicroStation Programming site.

A This solution was provided by Leonard Jones, a MicroStation staffer and Python evangelist.

Python Implementation

This code first creates a line element using the DraftingElementSchema. Then it make a copy of the line, also using the DraftingElementSchema.

 # Create line element using Curve Vector
    curve_elm = CurveVector.CreateLinear(points, CurveVector.eBOUNDARY_TYPE_Open)

    if BentleyStatus.eSUCCESS != DraftingElementSchema.ToElement(line_eeh,
                                    curve_elm, None, ACTIVEMODEL.Is3d(), ACTIVEMODEL):
        return False

    # Add the line element to model
    if BentleyStatus.eSUCCESS != line_eeh.AddToModel():
        return False


    # Line1 element with Offset
    offset_distance = 1.5*mu
    offset = CurveOffsetOptions(offset_distance)
    curve_elm = curve_elm.CloneOffsetCurvesXY(offset)

    if BentleyStatus.eSUCCESS != DraftingElementSchema.ToElement(line_eeh1,
                                    curve_elm, None, ACTIVEMODEL.Is3d(), ACTIVEMODEL):
        return False

    # Add the line element to model
    if BentleyStatus.eSUCCESS != line_eeh1.AddToModel():
	    return False

Questions

Post questions about MicroStation programming to the MicroStation Programming Forum.