We are using a customized version of the SmartObjects VBA Project and it is working as expected for some features but not others. The tool cannot rotate cells upon initial import as the lines are not created until all the points are displayed. So the project requires a manual redraw of the survey fieldbook before the cells will rotate.
We are using it for two types of cells. The ones that work are pavement marking symbols, like turn arrows and word appliques (ONLY, LEFT, SCHOOL, etc.). The only caveat is that sometimes the direction of the nearby lines (road striping) results in the symbol being out by 180 degrees. The ones that are not working are our Guy Wire Anchor Cells. These are usually draw using a JPT code, unlike the road striping. Since that seems to be the only difference between the two, I wonder if the rotate code just cannot work on JPT lines. Of if the fact that the segment shares a coincident point with the cell is the problem.
I welcome any suggestions.
BYW, this is a sort of update to an older thread, but it is a newer version and more information. If anyone has managed to get a Guy Anchor cell to rotate, I would love to find out how.
I revisited our code. It seemed like the easiest solution was to make two different cell rotation macros. The delivered version is great for aligning to nearby linear elements. The new one I created is expressly for aligning cells with a linear element that shares a common point.
Once I've cleaned it up I will see about sharing it. It will end up in our CAD Standards. but the web versions are always behind the PW Managed Workspace and internal versions.
Charles (Chuck) Rheault CADD Manager
MDOT State Highway Administration
Hi Chuck,
I'm currently wrestling with these different scenarios. Rotating pavement markings, guy wire cells, signs, light fixtures, gate posts, etc. It looks like we were able to rotate some cells to linear elements in the file by modifying the SmartObjects macro. Would you be up to sharing the code that you have created? Maybe we could massage it to work with our cells. I do have some code that allows the rotation of a cell to another cell and it works fine as long as there are not other same named cells within the search area, it gets confused and is not reliable. Bentley removed the JNC code that allowed us to join one point to another and this would rotate a cell in the file to its mate cell. I know this may sound rather confusing to others who have not tried to resolve these issues but figured you might understand since you have a lot of history with this.
I can't speak to the logic in the macro that Bentley provides, but the rotation is based on the imported linework. Each point cell that is imported is placed at its rotation as it has been created in your cell library by default. Once the data is imported through the Survey workflow into a field book, ORD attaches a vba macro rotation string to each of the point cells you identify in your Survey Settings. Once all of the graphics are present, you intitiate a "Redraw" from the Survey workflow. The software applies the rotation to the cell based off of whatever linear feature you define. If you have a linear feature like EO for edge of pavement, the cell is rotated to that linear feature.
The smartobjects.mvba macro needs to be loaded into your file through the VBA Manager. If you set it to load on startup, you never have to repeat this step again.
The following images show the code that is applied to each point cell. I've highlighted an SBIKE pavement marking cell as a specific example. Generally, the survey crew knows which direction to take their shots in the field and keep that consistent so that the line to rotate the cell to is consistent.
The code calls out: Survey,Annotate,RotateCell,25,EO,GLIP,0
Survey.Annotate,RotateCell is the call for the function within the MVBA.
25 is the distance in feet to search.
EO and GLIP are the linear elements we search for. (We updated the Bentley macro to include 2 elements to search for because sometimes one is not present).
0 indicates the angle to rotate to relative to the line that the macro found.
This is the "Redraw" tool you press that applies the code to all the points that were identified during the import process.
The VBA Macros are enabled in the Survey Settings and within the Vba Feature Macros property, you assign a VBA macro to specific field codes.
For example, we have a code LTAR which is a Left Turn Arrow pavement marking. Its VBA Feature Macros dialog entry is:
SmartObjectsSHA,SHA0201,RotateCell,V-MRKG-LINE,8
&&SmartObjectsSHA,SHA0201,LabelAttr,Annotation\Survey\Label\Traffic\Marking
The VBA Macro field actually contains instructions for two macros. The && is used to indicate the second macro. In the dialog box, that field is all on one line and in a non-resizable dialog box, is kind of a pain. Thats why we usually use the Import and Export buttons. Anyway, the syntax is described in the macro's comment header. The first three arguments are the macro project name, module name and procedure name to run: SmartObjectsSHA,SHA0201,RotateCell. The next argument the level that contains the linear element that will be used as a guide to orient the rotation. And the last argument (of macro-1) is the distance from the cell to search for the linear element. Since this is a lane marking symbol, and lanes are generally 12 feet wide, 8 feet usually guarantees that there will be a lane line on level V-MRKG-LINE within 8 feet of the cell.
The second macros is a label macro. It is designed to label specific attributes for survey features.. The fourth argument is the Element Template to use when placing the label. In the Element Template, is specifies any symbology or text properties necessary for the label. And in the macro code, are tests for different types and values and the label is placed only if needed and with the desired content.
We also found that sometimes the direction of the lane lines results in an arrow that is 180 degrees from the correct orientation. So we added an attribute named FLIP. If FLIP is empty, the cell is left alone. But if we add any value to FLIP, like TRUE, or YES or X or 1, thee cell is rotated by 180 degrees.
It sounds like the Bentley macros have been improved, but since we had already perfected our setup, we went with the adage, "If it ain't broke, don't fix it!"
Thank you for this! I'm working on a rotate cell to another cell macro now. I am not a programmer but can stumble my way around with some help. If you would like to see where that process is at, you can look at the following thread.
(+) Is there a macro that will rotate a cell to align with another cell? We used to be able to do this by using the JNC code in Survey with InRoads. - Civil Programming Forum - Civil Programming - Bentley Communities
If my file is very simple as in the example provided, it works flawlessly. I am trying to see if I can add code to search for the nearest instance of a cell to rotate to. Otherwise, we would require the field surveyors to add another code to identify the cell to rotate to. As an example, a down guy point cell to a wooden or steel pole.
The JNC code drew a line from one point to another. This was similar to JPT, except instead of another code, you specify a point number. We had some crews that never used JNC, but all crews often had to use JPT because sometimes, the nearest by code point was not where the line needed to be drawn. So, switching from JNC to JPT is not a huge effort. And the rotate cell tool can look for the line drawn by the JPT code to rotate the cell.
Thanks for the insight. I'll pass it on to my Survey guys.