Macro's in X12


Recommended Posts

OK, so today I learned that Legacy is just a fancy term for obsolete.  See, I do know how to search :) 


I have numerous macros, from others and some I wrote.  Has there been any enhanced documentation regarding what "migrating" is going to do to my macros and what I can expect? Or how to fix issues? Is this going to put the brakes on my workflow?  I know enough to write small macros for menial tasks, but I do not have an extended knowledge.


Or is this just not a big deal?



Link to comment
Share on other sites

  • Macros from versions before X12 that have not been migrated should continue working in X12. You do not need to do anything if you merely want to use your existing macros or new macros that don't interact with your existing macros.
    • However, referencing a legacy macro that has not been migrated from a new macro written in X12 (or vice versa) might cause an error.
  • During the migration process you will be able to compare the results of the macro before and after migrating and have the opportunity to make changes if needed.
    • Not all macros will require any changes while migrating.
  • For more information, see "Considerations for Legacy Files" and "Migrating Legacy Ruby Code" in Help.
Link to comment
Share on other sites

The key here is that any distance or area attribute that was a "Floating Point" number in X11 is a "Measurement" in X12.  If you migrate a macro it will assume it's using the X12 "Measurement" data type and might not work the way it did in X11.


"Measurements" recognize a "unit" such as inches, feet, sqft, etc.  You can add, subtract, multiply or divide like measurement units - but you can't add or subtract a floating point or integer number to a measurement.


If you want to migrate your macros you have to make sure you follow those rules (and there are some more rules) ---- or make sure you convert attributes using .to_f in order to avoid execution errors.


My suggestion is to not migrate unless you are sure of what you are doing. 


I've taken the time to modify all my macros to work in X12 - it was not a trivial effort.  When I create new macros I try to use the "Measurements" but it requires understanding and implementing several new methods that are unique to Chief's X12 Ruby.  The Measurement Class is not a standard Ruby Class - it's an add-on created by CA.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in

Sign In Now

  • Member Statistics

    Total Members
    Most Online
    Newest Member
  • Similar Content

    • By Scogginator
      Is there a way to write a custom command to auto-place lights?
      I've used chat GTP to write code that I'd like to utilize. I have attached a word file and pdf that I need proof read and corrected. I can have that done.
      Below is the code, but I'm not sure if it will format correctly:
      Sub PlaceLights()
          'Ask the user to select the room size and ceiling height
          Dim roomWidth As Double
          Dim roomLength As Double
          Dim roomHeight As Double
          roomWidth = InputBox("Enter the width of the room in feet:")
          roomLength = InputBox("Enter the length of the room in feet:")
          roomHeight = InputBox("Enter the height of the room in feet:")
          'Calculate the square footage of the room based on user input
          Dim roomArea As Double
          roomArea = roomWidth * roomLength
          'Determine the recommended lighting level for the room based on the ceiling height and room type
          Dim lightLevel As Double
          Select Case roomHeight
              Case Is <= 8
                  lightLevel = 10
              Case Is <= 9
                  lightLevel = 20
              Case Is <= 10
                  lightLevel = 30
              Case Is <= 12
                  lightLevel = 40
              Case Else
                  MsgBox "Invalid ceiling height"
                  Exit Sub
          End Select
          'Calculate the number of lights needed based on the room size and the recommended spacing
          Dim lightSpacing As Double
          If roomArea <= 100 Then
              lightSpacing = 48
          ElseIf roomArea <= 225 Then
              lightSpacing = 64
          ElseIf roomArea <= 400 Then
              lightSpacing = 80
              lightSpacing = 96
          End If
          Dim lightCount As Integer
          lightCount = Application.RoundUp((roomWidth + roomLength) / lightSpacing, 0)
          'Determine the optimal spacing for the lights based on the room size and ceiling height
          Dim xOffset As Double
          Dim yOffset As Double
          If roomWidth >= roomLength Then
              xOffset = lightSpacing
              yOffset = lightSpacing * roomLength / roomWidth
              xOffset = lightSpacing * roomWidth / roomLength
              yOffset = lightSpacing
          End If
          'Place the lights in a rectangular or square pattern within the room
          Dim lightType As String
          lightType = InputBox("Enter the light diameter (4 or 6):")
          Dim x As Integer
          Dim y As Integer
          Dim light As Object
          For x = 1 To lightCount
              For y = 1 To lightCount
                  Set light = ActiveDocument.CreateLight("Recessed Can Light", lightType & """", "General")
                  light.Move (x - 1) * xOffset, (y - 1) * yOffset, roomHeight - 48
              Next y
          Next x
          'Generate a report or summary of the lighting plan for the room
          Dim report As String
          report = "Room Size: " & roomWidth & " ft x " & roomLength & " ft" & vbCrLf
          report = report & "Ceiling Height: " & roomHeight & " ft" & vbCrLf
          report = report & "Recommended Light Level: " & lightLevel & " lux" & vbCrLf
          report = report & "Number of Lights: " & lightCount ^ 2 & vbCrLf
          report = report & "Light Spacing: " & lightSpacing & " in" & vbCrLf
          report = report & "Light Type: " & lightType & """ Recessed Can Light" & vbCrLf
          MsgBox report
      Any help would be appreciated.
      Sub PlaceLights.docx Sub PlaceLights.pdf
    • By Allen43
      I have returned to this forum once again in seek some help with ruby and macros.
      I have been working on a macro to automate cabinet labels. So far I have a mostly working macro, but I feel like my hands are tied and my eyes are closed. First of all the documentation on chief implementation of ruby and its capabilities it really lacking. And second, I don't have the Ruby terminal. I think this is because I am running Interiors, but am not sure as all Chief says is that there is limited use of Ruby in this version.
      Anyways, right now I would love to have a list of all callable object attributes. I honestly don't even know if that is the right name for what I am looking for. I am trying to find a list of what info I can scrape from a cabinet. So, what can I put after obj. (ie. obj.width, obj.type)? I think I could find this by running the selected.names command in the terminal, but I have no way of knowing.
      This is my current macro. It is built from parts of a macro from @MarkMc and whatever I have been able to come up with from random trial and error. If you see something I could improve on, I am open to suggestions as long as they have a good explanation with them. Thanks in advance!
      obj = owner
      obj = referenced unless referenced.nil?
      type = obj.type.to_s
      nf =
      nf.unit = 'in'
      nf.use_fractions = true
      nf.show_unit = false
      standard_size = 24.0 if type == 'base_cabinet'
      standard_size = 12.0 if type == 'wall_cabinet'
      standard_size = 24.0 if type == 'full_height_cabinet'
      depth = nf.apply(obj.depth) if obj.depth.to_f != standard_size
      standard_size_height = 36 if type == 'base_cabinet'
      standard_size_height = 0.0 if type == 'full_height_cabinet'
      height = nf.apply(obj.height) if obj.height.to_f != standard_size_height
      width = nf.apply(obj.width)
      nomen = 'B' if type == 'base_cabinet'
      nomen = 'W' if type == 'wall_cabinet'
      nomen = 'T' if type == 'full_height_cabinet'
      hinging = owner.door_swing
      label = ""
      label << nomen << width.to_s << height.to_s << depth.to_s << hinging
      p label
    • By Ange822
      Hi there - I am upgrading from X12 to X14, I have been able to export / import my hot keys and User Catalogues, any ideas how to export / import the Chief Bonus Catalogs and Manufacturer Catalogs without exporting each individual library?

    • By Allen43
      I'll new to Chief and have learned that this form might be one of the best resources I have ever used. I am trying to streamline my design process and to do that I would love to be able to change cabinet ends to finished or paneled faster and easier. I tried to make a SP to do this, but I couldn't figure it out. I also thought that there might be a way to do this with macros is a SP, but I know even less about macros than I do Chief.
      Any help is appreciated, and if it's not possible that's fine I'll know not to spend more time on this.
    • By dandrconcepts
      Looking to get insight on framing a pole barn on x12. I’ve read some articles but none have completely helped me. Any one with some input would greatly be appreciated.