Written by Rod Wing
Anyone who has done any MicroStation VBA programming, or recorded a MicroStation VBA macro, knows about the CADInputQueue class. Many beginning VBA programmers will run into problems using the CADInputQueue.SendDataPoint method. They want to select a particular MicroStation element, but their data point intersects with another element and the macro picks the wrong one.
The CADInputQueue.SendDataPointForLocate method lets you get around this problem. Besides the Point3D data point argument it also takes a MicroStation graphical element type: CADInputQueue.SendDataPointForLocate (ElementToLocate, DataPoint). This method will select the specified element at the data point provided.
Below is an example of the CadInputQueue.SendDataPointForLocate method in action. This function extrudes a circle along a line element to create a 3D surface to represent a pipe. Since pipe networks are likely to have line elements with common start/end points it is important we identify the correct line when extruding the surface. The CadInputQueue.SendDataPointForLocate method allows this to happen.
Public Function ExtrudeSurfaceAlongPath(elPath As LineElement, dRadius As Double, KeepPath As Boolean) _ As Boolean ExtrudeSurfaceAlongPath = False On Error GoTo EXIT_SUB ' Start Surface By Extrusion Along tool CadInputQueue.SendCommand "CONSTRUCT SURFACE ALONG" ' ' Set tool settings ' ' set Alignment to Normal SetCExpressionValue "tcb->ms3DToolSettings.smartSolid.tube.surfaceAlign", 0, "3DMODIFY" ' toggle off unneeded checkboxes SetCExpressionValue "tcb->ms3DToolSettings.smartSolid.tube.surfaceScale", 0, "3DMODIFY" SetCExpressionValue "tcb->ms3DToolSettings.smartSolid.tube.surfaceSpin", 0, "3DMODIFY" SetCExpressionValue "tcb->ms3DToolSettings.smartSolid.tube.surfaceLockDir", 0, "3DMODIFY" SetCExpressionValue "tcb->ms3DToolSettings.smartSolid.tube.surfaceRepair", 0, "3DMODIFY"
' toggle on Circular and Radius checkboxes SetCExpressionValue "tcb->ms3DToolSettings.smartSolid.tube.surfaceMode", 1, "3DMODIFY" SetCExpressionValue "tcb->ms3DToolSettings.smartSolid.tube.surfaceRadiusLocked", 1, "3DMODIFY" ' set radius value SetCExpressionValue "tcb->ms3DToolSettings.tubeSurfRad", _ (ActiveModelReference.UORsPerMasterUnit * dRadius), "3DMODIFY"
' set Keep Path toggle If KeepPath Then SetCExpressionValue "tcb->ms3DToolSettings.smartSolid.tube.surfaceKeepPath", 1, "3DMODIFY" Else SetCExpressionValue "tcb->ms3DToolSettings.smartSolid.tube.surfaceKeepPath", 0, "3DMODIFY" End If
' ' Select element and accept ' CadInputQueue.SendDataPointForLocate elPath, elPath.StartPoint CadInputQueue.SendDataPoint elPath.StartPoint ' ' Reset to complete ' CadInputQueue.SendReset ' ' All done so start default command and exit ' CommandState.StartDefaultCommand ExtrudeSurfaceAlongPath = True
EXIT_SUB: End Function
Last month’s tips:
![cache manager](https://envisioncad.com/wp-content/uploads/2014/07/cache-manager-150x150.png)
![inroads end condition priority](https://envisioncad.com/wp-content/uploads/2014/08/inroadsendconditionpriority-150x150.png)
![Migrating Data Shortcuts](https://envisioncad.com/wp-content/uploads/2014/07/notes-11-150x150.png)
![With Statement](https://envisioncad.com/wp-content/uploads/2014/09/7-22-2014-11-04-26-AM-150x150.png)
![EnvisionCADs Linkedin Group EnvisionCAD Group](https://envisioncad.com/wp-content/uploads/2012/02/LinkedinLogo.png)
![EnvisionCADs YouTube Channel EnvisionCAD YouTube Channel](https://envisioncad.com/wp-content/uploads/2012/02/YouTubeLogo.png)
![EnvisionCADs Facebook Page](https://envisioncad.com/wp-content/uploads/2012/02/FaceBookLogo1.png)
![EnvisionCAD Twitter](https://envisioncad.com/wp-content/uploads/2012/02/TwitterLogo.png)
![Newsletter Archive](https://envisioncad.com/wp-content/uploads/2012/02/NewsletterGraphic.png)