Page 1 of 2 12 LastLast
Results 1 to 15 of 29
  1. #1
    Join Date
    Oct 2012
    Posts
    12

    More Macro Help!

    Here is my situation. I am looking to create a text macro that I can show fractions. With my different joist, roof, and wall size callouts, I am wanting to use text macros for it. However the issue I am running into is that fractions do not show up how I want them to. I am wanting them to look like this....."11-7/8". However, they keep showing up as decimals...understandably because it is a division symbol. Am I missing something obvious?

    JBaehmer

  2. #2
    Join Date
    Oct 2009
    Posts
    904
    I believe Joe Carrick posted the Macro for this several times. You might want to search his previous posts in the last couple of months.

    BUT --- BUT here's the macro. -- Where value = your variable.

    arr = value.divmod(12)
    inch_frac = ((arr[1]-arr[1].floor)*16).round.quo(16)

    result = case inch_frac
    when Rational(1.0)
    "#{arr[0]}'-#{arr[1].ceil}\""
    when Rational(0.0)
    "#{arr[0]}'-#{arr[1].floor}\""
    else
    "#{arr[0].floor}'-#{arr[1].floor} #{inch_frac}\""
    end
    result

    If you don't want to copy this code for every macro or value, just create a method containing the above. Put the macro containing the method somewhere in your plan and use as: example

    result = ft_in(ceiling_elevation)

    Don't forget to check evaluate and select the reference as appropriate. Attached is reference method macro.
    Gerry

    NewCraft Home Services

    Design/ Compliance Review
    PE, X6 , Sketchup 8, TurboCad Pro 20
    -----------------------------------
    ASUS P9X79D, i7-3820, GTX680 w/4gb
    -----------------------------
    If the Government would just cut down more d*** trees, I'd have a much better view of the forest.

  3. #3
    Join Date
    Jun 2003
    Location
    Kamiah, Idaho
    Posts
    4,206
    Thanks Gerry
    Curt Johnson

    X5

    Puget Systems Custom Computer, Win 7 Pro 64-bit SP1, 3.3Ghz Intel Core i5 2500K Quad, 8 GB Kingston DDR3-1333 Ram, Intel X25-M 80 GB SSD App Drive, WD 500 GB Caviar Blue SATA 6 Gb/s Data Drive, EVGA GeForce GTX 550 Ti 1024MB VC, Antec 650W PS, Asus p8P67 Pro REV 3.0 Motherboard

  4. #4
    Join Date
    Oct 2012
    Posts
    12
    Thanks! I am very new to these macros so, some of this is going way over my head. I imported the .json file, but I don't see where I can change what I want to input into the macro. I appears that the macro is looking for reference points within the plan file such as ceiling and floor levels. I am looking for something similar to the basic text macro that I learned from one of Scott's videos where I just enter a "5" in the macro and it changes it every where that I have placed that text macro. No ruby elements were involve with it. I tried looking up the specific thing I am looking for through Joe's Posts and Scott's videos, but not seeing it. If I am completely missing the boat on what you were saying I am sorry. Blaming it on my complete inexperience with macros in CA

    Does anyone know if there is anything in the works for a macros workshop on a weekend or something? I would be 100% game to get in on that.

    Jared

  5. #5
    Join Date
    Jan 2007
    Location
    San Marcos, CA
    Posts
    6,805
    Jared,

    What you need to do is set a variable in the macro and use that in place of ceiling_height like this:

    value = 5
    arr = value.divmod(12)
    inch_frac = ((arr[1]-arr[1].floor)*16).round.quo(16)

    result = case inch_frac
    when Rational(1.0)
    "#{arr[0]}'-#{arr[1].ceil}\""
    when Rational(0.0)
    "#{arr[0]}'-#{arr[1].floor}\""
    else
    "#{arr[0].floor}'-#{arr[1].floor} #{inch_frac}\""
    end
    result

    This would be a Non-Evaluated Macro. When a macro is referenced it needs to have an arrow pointing to the object that it's supposed to get info (such as "ceiling_elevation") from.
    Joseph P. Carrick, Architect - AIA
    ASUS M51AC Desktop, core i7-4770 CPU @3.4 GHZ, 16 GB Ram, NVidea GT640 with60M with 3GB GM, 30" HiRes (2560/1600) Monitor , (2) 24" ASUS Monitors
    Windows 8.1
    Chief Architect 9, 10, X1, X3, X4 Premium, X5 Premium, X6 Premium

  6. #6
    Join Date
    Oct 2009
    Posts
    904
    Quote Originally Posted by jbaehmer View Post
    Does anyone know if there is anything in the works for a macros workshop on a weekend or something? I would be 100% game to get in on that.

    Jared
    My apologizes , I ASS U ME that this was a continuation of previous threads to change Chief's Ruby return format to ft-in.
    It appears that you just need a units converter.
    Suggest you search the web, there are a lot of free ones that will do this.

    The example assumes you want to convert a Chief return value. To use it directly, just sub (enter) your value for the item within the brackets. i.e.

    ft_in(315.64) = 26'-3 5/8"

    Now -- sorry - AFAIK -- there are no training sessions or videos scheduled by Chief on Macros. At present, Chief does not provide much support on macros and the feature is EXTREMELY limited. Likewise, there's not much help offered on this forum because there aren't many useful features to demo. (vs learning effort).

    Although this feature draws a lot of interest, Chief has not provided any encouragement of any future expansion or support to make this tool useful and it's doubtful they will. Only you can decide if the effort to learn and use such a limited tool is valuable. Many do use some elementary features of this tool --- most don't.


    EDIT ---OOOPs -- Joe got here first and didn't see his post - Thanks Joe!!
    Last edited by gteacher; 10-07-2013 at 08:41 AM. Reason: Update for previous post
    Gerry

    NewCraft Home Services

    Design/ Compliance Review
    PE, X6 , Sketchup 8, TurboCad Pro 20
    -----------------------------------
    ASUS P9X79D, i7-3820, GTX680 w/4gb
    -----------------------------
    If the Government would just cut down more d*** trees, I'd have a much better view of the forest.

  7. #7
    Join Date
    Jan 2007
    Location
    San Marcos, CA
    Posts
    6,805
    Gerry,

    I need some help with initializing Global_Variables.

    Chief saves Macros and Global Variables with the Plan/Layout but doesn't save the Values of Global Variables. When I open a Plan, all the Global Variables are present but they are all "nil". How can I determine within a macro if any variable is "nil" so I can set it to something that's valid ("",0,[]) ?

    Some of my macros need to initialize their values just once when the Plan is opened. Of course I can do this by opening a CAD Detail that contains an initialization macro to set all Global Variables to initial values but I would really like to eliminate that step.

    Thanks, Joe
    Joseph P. Carrick, Architect - AIA
    ASUS M51AC Desktop, core i7-4770 CPU @3.4 GHZ, 16 GB Ram, NVidea GT640 with60M with 3GB GM, 30" HiRes (2560/1600) Monitor , (2) 24" ASUS Monitors
    Windows 8.1
    Chief Architect 9, 10, X1, X3, X4 Premium, X5 Premium, X6 Premium

  8. #8
    Join Date
    Oct 2012
    Posts
    12
    Thank you! that was a huge help!

  9. #9
    Join Date
    Oct 2009
    Posts
    904
    Joe:

    We might have to exchange a few posts in order to get an understanding of what you need.

    But – here’s what I think I know (ASS U ME).

    Global variables indeed are not persistent. They also cannot be used in program flow because the order of macros cannot be controlled and, as I understand it, will NOT be so in the future.

    So, if used, they must be initialized and re-calculated each cycle without regard to order or usage. Very wasteful, but since usage is so limited, not usually noticeable (for the benefit of those that came in late).

    Depending on what you need to initialize and control, there are several approaches.

    For a common variable – no need. Ruby is a dynamic language and will automatically create the variable upon any calculation. The exception is if you want to store in something like an array or hash. Those must be already present or created manually. You do this by first testing if they are present and, if not, create them as in:

    if (! myarray.nil?) then
    myarray = Array.new
    end

    ORRRR

    if (!myhash.nil?) then
    myhash = Hash.new
    end

    Note the use of the nil? Method (message). The testing need only be done in one macro somewhere in plan.

    If your trying to use a variable as a constant, you can initialize through use of an external file or by a utility macro placed somewhere in your plan that does not return anything (nil). It must be in your plan because it initially will not run if just in the Macro Edit DBX—those macros only run when the DBX is opened (tested). This is wasteful since, if in plan, it will also re-run on every cycle, but since they are constants – no harm – just wasteful. Also macros ONLY run if a plan is open - selected/viewed - This may be your problem. You can put initialization macros in multiple places and as long as they don't conflict.

    I’m sure I missed some point. If you can narrow your question, I’ll try again
    Gerry

    NewCraft Home Services

    Design/ Compliance Review
    PE, X6 , Sketchup 8, TurboCad Pro 20
    -----------------------------------
    ASUS P9X79D, i7-3820, GTX680 w/4gb
    -----------------------------
    If the Government would just cut down more d*** trees, I'd have a much better view of the forest.

  10. #10
    Join Date
    Jan 2007
    Location
    San Marcos, CA
    Posts
    6,805
    Gerry,

    I think:

    if (! $myarray.nil?) then
    $myarray = []
    end

    is what I need. But perhaps:

    if $myarray.nil?
    $myarray = []
    end

    would be correct. IOW, if $myarray is nil then I want to initialize it as an empty array. That way any other macro that needs to use $myarray will be able to work with it as an array. Generally for string and numerical values it's not so much of a problem because the macro can afford to initialize those values each time the macro is called.

    I had tried just about everything to test for nil - except .nil? Non of my Ruby docs mentioned that method.
    Joseph P. Carrick, Architect - AIA
    ASUS M51AC Desktop, core i7-4770 CPU @3.4 GHZ, 16 GB Ram, NVidea GT640 with60M with 3GB GM, 30" HiRes (2560/1600) Monitor , (2) 24" ASUS Monitors
    Windows 8.1
    Chief Architect 9, 10, X1, X3, X4 Premium, X5 Premium, X6 Premium

  11. #11
    Join Date
    Oct 2009
    Posts
    904
    My bad - engage fingers before brain

    if (myarray.nil?)
    $myarray = []
    end

    is correct. Also $myarray = [] & $myarray = Array.new are the same thing.

    Also,If you want to serialize data externally from plan to plan, you may want to look at marshaling.(Yaml better but not avail in Chief).
    Gerry

    NewCraft Home Services

    Design/ Compliance Review
    PE, X6 , Sketchup 8, TurboCad Pro 20
    -----------------------------------
    ASUS P9X79D, i7-3820, GTX680 w/4gb
    -----------------------------
    If the Government would just cut down more d*** trees, I'd have a much better view of the forest.

  12. #12
    Join Date
    Jan 2007
    Location
    San Marcos, CA
    Posts
    6,805
    Thanks Gerry,

    I don't need to serialize but here's what I came up with:

    if $DeckNames.nil?
    $DeckNames = []
    $DeckAreas = []
    $BalconyNames = []
    $BalconyAreas = []
    $CourtNames = []
    $CourtAreas = []
    $PorchNames = []
    $PorchAreas = []
    $FirstFloorLiving = 0
    $SecondFloorLiving = 0
    $ThirdFloorLiving = 0
    $BasementArea = 0
    $BonusRoomArea = 0
    $GarageArea = 0
    $GarageName = "GARAGE"
    $Area_Buildable = 0
    $Area_Building = 0
    $Area_Driveway = 0
    $Area_Patio = 0
    $Area_Property = 0
    end
    ""


    I put the macro in my LIVING AREA label on each floor. When the Plan is opened it initializes the values and then leaves them alone so that the values are there and can be used/updated as appropriate by other macros.
    Joseph P. Carrick, Architect - AIA
    ASUS M51AC Desktop, core i7-4770 CPU @3.4 GHZ, 16 GB Ram, NVidea GT640 with60M with 3GB GM, 30" HiRes (2560/1600) Monitor , (2) 24" ASUS Monitors
    Windows 8.1
    Chief Architect 9, 10, X1, X3, X4 Premium, X5 Premium, X6 Premium

  13. #13
    Join Date
    Jun 2005
    Location
    Southern California
    Posts
    4,874
    Looks Greek to me, Can't follow but, a huge thanks for trying. You guys rock.
    Perry
    P.H. DESIGNS L.L.C.
    Eastvale Calif.
    Alienware, liquid cooled
    Ver 10-"X6 x64 SSA
    WIN 8.1 PRO 64 bit
    Nvidia GTX780 3GB.
    i7 920 2.67-- 12 GB Ram
    40" led monitor

  14. #14
    Join Date
    Jan 2007
    Location
    San Marcos, CA
    Posts
    6,805
    Perry,

    Essentially, I use the Global_Variables as a place to keep values as follows:

    $DeckNames = ["Dummy", "Deck #1", "Deck #2", "Deck #3"]
    $DeckAreas = [0, 200, 130, 60]

    When a Plan is opened I initialize all my global_variables as I show in the post above. That way, any macro that needs to get data from one of them has a value to work with.

    The square brackets identify these as Arrays and I can retrieve the value of $DeckNames[2] and get "Deck #2" (arrays are numbered starting at 0 so i just put a dummy value in the first position. I place the macro that sets the values in the room label and it puts the name of the Deck (must be unique) in $DeckNames and the standard_area in $DeckAreas at the correct indexed position. If the name already exists it just updates the area in that position - otherwise it adds the name and the area to the corresponding arrays.

    In order to get the total area of all decks, I have another macro that goes thru $DeckAreas and adds them all and displays the total.

    I do this for Decks, Courts, Balconies and Porches.

    I'm working on doing it for "Unspecified" rooms since they are generally not included in "Living Area" and it allows me to calculate the "Gross Floor Area". GrossFloorArea = $FirstFloorLivable + FirstFloorNonLivable + ...........

    The only critical item is that each Deck, Balcony, Court, Porch and Unspecified room have a unique name that is displayed. It has to be displayed in order to force the macro embedded in the label to work.

    The "Living Area" of each floor is retrieved by using another macro attached to the "LIVING AREA" label of each floor.

    My basic purpose with all this is an automated method of filling in the Project Area Analysis which is in a CAD Detail that is sent to Layout.

    This system insures that if something is changed in the Plan the numbers will automatically all be correct in the Project Area Analysis.
    Joseph P. Carrick, Architect - AIA
    ASUS M51AC Desktop, core i7-4770 CPU @3.4 GHZ, 16 GB Ram, NVidea GT640 with60M with 3GB GM, 30" HiRes (2560/1600) Monitor , (2) 24" ASUS Monitors
    Windows 8.1
    Chief Architect 9, 10, X1, X3, X4 Premium, X5 Premium, X6 Premium

  15. #15
    Join Date
    Jun 2005
    Location
    Southern California
    Posts
    4,874
    Thanks for the explanation, still fuzzy but I trust you guys to get it right.
    Perry
    P.H. DESIGNS L.L.C.
    Eastvale Calif.
    Alienware, liquid cooled
    Ver 10-"X6 x64 SSA
    WIN 8.1 PRO 64 bit
    Nvidia GTX780 3GB.
    i7 920 2.67-- 12 GB Ram
    40" led monitor

 

 

Posting Permissions

  • Login or Register to post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •