I am having to change the settings > Design File>Working Units. I have tried the VBA record over and over It seems to record some of it
in a Macro9ModalHandler, I actually have a 6, 7, 8, and the 9
but when you run the macro, does not seem to make the changes
the Key-In "set units inches inches" works fine but I need Inches Custom
This is the starting format
This is what I am trying to achieve , how ever possible KeyIn or VBA, Next is the Custom Window and the settings needed
This is Custom Settings
Now I will put up the 1 of many test Macros trying to achieve this
Sub Macro12() 'Dim startPoint As Point3d 'Dim point As Point3d, point2 As Point3d Dim lngTemp As Long ' Send a keyin that can be a command string CadInputQueue.SendKeyin "set units inches inches" CadInputQueue.SendKeyin "Set" Dim modalHandler As New Macro12ModalHandler AddModalDialogEventsHandler modalHandler ' The following statement opens modal dialog "Design File Settings" ' Start a command CadInputQueue.SendCommand "MDL SILENTLOAD DGNSET" CadInputQueue.SendCommand "MDL SILENTUNLOAD DGNSET" RemoveModalDialogEventsHandler modalHandler CommandState.StartDefaultCommand End Sub
This is the 12th attempt with VBA record, finally the Macro12ModalHandler
Option Explicit Implements IModalDialogEvents Private Sub IModalDialogEvents_OnDialogClosed(ByVal DialogBoxName As String, ByVal DialogResult As MsdDialogBoxResult) End Sub Private Sub IModalDialogEvents_OnDialogOpened(ByVal DialogBoxName As String, DialogResult As MsdDialogBoxResult) If DialogBoxName = "Design File Settings" Then ' The following statement opens modal dialog "Define Custom Units" ' Set a variable associated with a dialog box SetCExpressionValue "dgnSet.cust_customSU", 1, "DGNSET" SetCExpressionValue "dgnSet.cust_subNumerator", 10, "DGNSET" SetCExpressionValue "dgnSet.subUnitInfo.label", "TH", "DGNSET" ' Remove the following line to let the user close the dialog box. DialogResult = msdDialogBoxResultOK End If ' Design File Settings If DialogBoxName = "Define Custom Units" Then ' Set a variable associated with a dialog box SetCExpressionValue "dgnSet.cust_customSU", 1, "DGNSET" SetCExpressionValue "dgnSet.cust_subNumerator", 10, "DGNSET" SetCExpressionValue "dgnSet.subUnitInfo.label", "TH", "DGNSET" ' Remove the following line to let the user close the dialog box. DialogResult = msdDialogBoxResultOK End If ' Define Custom Units End Sub
Not sure what else to put, I have looked in help, VBA help and Online, Jan hope this is correct ?
Sorry if this is a repost, the site auto-deleted my first post and tagged it as spam.Funny, first post in ages and I am a spammer. LOL
Anyhow...Richard, yes this is do-able. However I think the macro recorder is leading you astray.There may be a way to get it to record and do what you want, but my recommendation would be to do it the "hard" way.Or in your case, will need to learn some new things, and use the Unit Definition methods.
The below code snippet should do what you are asking for.Note that it appears you are requesting to change the file resolution from 10,000 units per meter to 100,000 units per inch.Just make sure that is actually what you desire to do, as if you have any existing data in the file with any sort of real scale, the end result will be whacked and non-sensical. If file is empty, or the scale of existing elements don't matter, then OK.Just pointing it out, as selecting the Edit button on the Advanced Settings button would warn you.So the code below should give you exactly what you "asked" for, just make sure it is actually what you "wanted".
' ---------------------------------------------------------------------- Public Sub WorkingUnits_Inch_Tenth() Dim mu As MeasurementUnit Dim su As MeasurementUnit Dim uor As MeasurementUnit ' Set up DGN working units as: ' Define our desired Unit Of Resolution (UOR) as ' 100,000 UOR per absolute storage unit (meter) and reflect in Inches ' Master Unit (MU) of Inches ' Sub Unit (SU) as One Tenth "TH" of an inch ' Create the unit definitions ' Note that all unit definitions are relative to metric standard ' So we define american units as conversion factors from meter ' First, define our desired UOR / Absolute Positional Unit ' relative to the standard Absolute Storage Unit of meter ' This is where the real magic happens and you are defining the ' conversion factor from 1 meter to your desired unit ' The stated goal was for UOR to be an inch ' 1 inch = 0.0254 meter With uor .System = msdMeasurementSystemEnglish .Label = "" .Base = msdMeasurementBaseMeter ' Units are stored as a fraction that will approximate the desired end result. ' Given 1 inch = 0.0254 meters, let's convert that to a fraction of a whole meter ' inches / meters = 1/0.0254 = Multiply to remove decimal (1/0.0254)*10000 ' Provides desired result of 10000 / 254 ' You can check yourself by doing the math and looking up official conversion. ' 1 meter = 39.3700787402 in , the result of the calculation is 39.37007874015748. Yup! .UnitsPerBaseNumerator = 10000# .UnitsPerBaseDenominator = 254# End With ' Now define our desired Master Units in Inches With mu .System = msdMeasurementSystemEnglish .Label = "IN" .Base = msdMeasurementBaseMeter ' Conveniently, in this case we want our Master Unit in Inches ' which in this case matches our desired definition of UORs in inches ' So we have the same values as above .UnitsPerBaseNumerator = 10000# .UnitsPerBaseDenominator = 254# End With ' Now define our desired sub unit of a Tenth of an inch With su .System = msdMeasurementSystemEnglish .Label = "TH" .Base = msdMeasurementBaseMeter ' Here we are wanting a result of 1/10 of above relative to UORS. ' We can accomplish this easily by multiplying the Numerator by 10 .UnitsPerBaseNumerator = 100000# ' For inches, we want 254 like above, because this is now 254 * 1/10 of our MU ' it will result in 1/10 of an inch as desired .UnitsPerBaseDenominator = 254# End With 'Now, we actually APPLY the desired unit changes we defined above With ActiveModelReference ' Define our desired Unit Of Resolution of 100,000 UORs per storage unit ' WARNING: Changing this value on existing files can totally whack your ' existing dimensions. It would have the effect of virtually scaling everything! ' So make sure this is really what you intend. .UORsPerStorageUnit = 100000 'Now, we apply the UOR Storage Unit definition to translate ' from universal meter to our desired unit of Inch .StorageUnit = uor 'Now, we apply our desired master and sub unit definitions .MasterUnit = mu .SubUnit = su End With ' Finally, desire to use coordinate format of MU:SU:PU ' This corresponds to global Coordinate Format setting of Working Units ActiveSettings.CoordinateFormat = msdWorkingUnits ' NOTE: Values are not stored permanently to design file until ' settings are saved. SaveSettings End Sub ' ----------------------------------------------------------------------
Enjoy,Gerald
Answer Verified By: Richard Phillips
SUPER, SUPER, THANK YOU so very much. I put your Macro 1st and than ran my 2 settings I already had and I get just what I wanted. I am so glad others can benefit from folks like you who know there stuff and take the time to share it. I so want to thank - G - or Mr. G, along with Jon Summers, and Jan and a few others along the way. Lorys Lee another great person of knowledge and willing to assist so many. I had actually given up and thought I would never get it. Esp. when Leonard Jones said He did not think it could be done. So please accept the special thanks of this old fella who is trying to improve his speed at getting work done for my company and keep my productivity improving so I can keep a part-time job with LSI an Amazing company with such talent. Thanks again to -G- and all who try to help this old bird keep his small income. (c8... God bless all
Version: MicroStation V8i SS 10
RJB Phillips III (Richard) Praise the Lord for His Mercy and grace in Christ Jesus