[V8i - VBA] CopyElement problems

Good morning friends,

in a 3D model, I have some 3D objects (Cells).  I did "Visible Edge Export" of each of them on the XY, XZ and YZ planes. And then Flatten Curve.

My desire is to copy each of these cells (They are cells because the lines obtained with Flatten Curve have been grouped - GROUP SELECTION command) from the 3d model of source Dgn to a target Dgn (2D model) using OpenDesignFileForProgram.

I read in the Microstation VBA Help that, with OpenDesignFileForProgram, is not possible make use of AddElement (is it correct?).

Then I utilised CopyElement, but I got some problems:

1. CellElements are 100 times greater (Both files, source and target, have the same working unit and active scale is set to 1 for x, y and z)

2. I got, in the target file, only one cell for each originary 3D cells in the right "persective" (please see the attached image) : top and left are wrong.

3. Cells Position, in the target file are not the asked ones (I suspected this problem could be linked to n.1 problem)

I tried to do a lot of attempts to solve those problems, without luck...

I insert the last one here (where I also added cells to source file too, to see if AddElement (Instead of CopyElement) works well...and all was right).

Sub CopyToSmartSketch()
    Dim myDgn As DesignFile
    Dim myCopyContext As New CopyContext
    
    ActiveDesignFile.Models("Default").AddElement myCellToExchange
    
    Set myDgn = OpenDesignFileForProgram("C:\Users\Paolo\Desktop\Celle\smartSketch.dgn", False)
    
    myCopyContext.ChangeUnits = True
    myCopyContext.MatchDimensionToDestination = True
    myCopyContext.LevelHandling = msdCopyContextLevelByUserPreference
    myCopyContext.ViewForFlattening = myPlane
    
    myDgn.Models("Default").CopyElement myCellToExchange, myCopyContext
    
    myCellToExchange.Origin.X = myOriginX
    myCellToExchange.Origin.Y = myOriginY
    
    myCellToExchange.Rewrite
    myCellToExchange.Redraw
    
    myDgn.RewriteLevels
    myDgn.Save
    myDgn.Close
End Sub

I searched on the web: I found a LA Solution to copy objects from 3D model to a 2D one, but (I didn't try it) I would like to write my own one.

Thanks a lot.

Best regards, 
Paolo

Parents Reply Children
No Data