Move/Copy Parallel ShapeElement

Hello All,

I had run a macro to offset a shape element (inside polygon).But i didn't get output shape element inside instead it was placed outside.how to accomplish this? please help.

Thanks in advance.

Kanmani kandaswamy.

Here is the code i have tried.

Private Function offsetBuffer(dist As Double, shp As ShapeElement, insidePt As Point3d) As ShapeElement
Dim startPoint As Point3d
Dim Point As Point3d, point2 As Point3d
Dim lngTemp As Long
Dim newElem As ShapeElement
Dim offElem As Element
Dim resltShp As ShapeElement

Set newElem = CreateShapeElement1(Nothing, shp.GetVertices)
ActiveModelReference.UnselectAllElements
ActiveModelReference.SelectElement shp

CadInputQueue.SendCommand "MOVE PARALLEL OFFSET "

SetCExpressionValue "tcb->ms3DToolSettings.offsetCurve.makeCopy", 1, "3DMODIFY"

CadInputQueue.SendCommand "MOVE PARALLEL OFFSET "
SetCExpressionValue "tcb->ms3DToolSettings.offsetCurve.activeSymb", 1, "3DMODIFY"

CadInputQueue.SendCommand "MOVE PARALLEL OFFSET "
SetCExpressionValue "tcb->ms3DToolSettings.offsetCurve.distance.value", (ActiveModelReference.UORsPerMasterUnit * dist), "3DMODIFY"
CadInputQueue.SendDataPoint insidePt,1
CadInputQueue.SendDataPoint Point3dZero, 1

CommandState.StartDefaultCommand

Set offElem = ActiveModelReference.GetLastValidGraphicalElement
Set offsetBuffer = offElem
End Function

  • Hi kanmani,

    at first, please use Syntaxhighlighter tool (yellow pencil icon) with properly set language (VB in your case) when posting any code. It ensures the code will be displayed and colorized properly as code, not as plain text (which is ugly).

    Also, don't duplicate your posts! You asked the same question in Developers and Programming forum, which is confusing, at least because it's not clear what question and related discussion is the right one.

    You did not mention what product and version (build number) do you use. E.g. V8i and CONNECT Edition behaviour can be quite different.

    Unknown said:
    But i didnt get output shape element inside instead it was placed outside.

    It's probably because of first and second points relative positions.

    Unknown said:
    how to accomplish this?

    To use MicroStation key-ins from the code, when user's actions have to be simulated, is often tricky. I guess there are two possible solutions:

    • You should calculate the correct position of the second point instead of using 0,0,0 automatically.
    • Alternatively you can use mdlElmdscr_copyParallel, better to say its VBA wrapper. It's more complex comapring to using MicroStation key-ins, but it should be more robust solution.

    I recommend to search this web for similar topic, because I remember copy parallel in VBA was discussed several times in the past.

    With regards,

      Jan