[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-0-en-105":3,"doc-seo-788085-105":59,"doc-detail-788085-en":129,"doc-similar-788085":158},{"code":4,"msg":5,"data":6},0,"success",[7,13,18,23,28,33,38,43,48,51,55],{"id":8,"doc_module":4,"doc_module_name":9,"category_name":10,"show_sort_weight":11,"slug":12},1,"Document","Story & Novel",90,"story-novel",{"id":14,"doc_module":4,"doc_module_name":9,"category_name":15,"show_sort_weight":16,"slug":17},2,"Literature",80,"literature",{"id":19,"doc_module":4,"doc_module_name":9,"category_name":20,"show_sort_weight":21,"slug":22},4,"Exam",70,"exam",{"id":24,"doc_module":4,"doc_module_name":9,"category_name":25,"show_sort_weight":26,"slug":27},5,"Comic",60,"comic",{"id":29,"doc_module":4,"doc_module_name":9,"category_name":30,"show_sort_weight":31,"slug":32},6,"Technology",50,"technology",{"id":34,"doc_module":4,"doc_module_name":9,"category_name":35,"show_sort_weight":36,"slug":37},7,"Healthcare",40,"healthcare",{"id":39,"doc_module":4,"doc_module_name":9,"category_name":40,"show_sort_weight":41,"slug":42},8,"Research & Report",30,"research-report",{"id":44,"doc_module":4,"doc_module_name":9,"category_name":45,"show_sort_weight":46,"slug":47},9,"Religion & Spirituality",20,"religion-spirituality",{"id":46,"doc_module":4,"doc_module_name":9,"category_name":49,"show_sort_weight":46,"slug":50},"World Cup","world-cup",{"id":52,"doc_module":4,"doc_module_name":9,"category_name":53,"show_sort_weight":52,"slug":54},10,"Lifestyle","lifestyle",{"id":56,"doc_module":4,"doc_module_name":9,"category_name":57,"show_sort_weight":24,"slug":58},19,"General","general",{"code":4,"msg":60,"data":61},"ok",{"site_id":62,"language":63,"slug":64,"title":65,"keywords":66,"description":67,"schema_data":68,"social_meta":122,"head_meta":124,"extra_data":126,"updated_unix":128},105,"en","1714641996091-conditional-g-code-best-practice","1714641996091 - Conditional G Code - Best Practice","","Conditional G-code lets machine instructions respond to firmware data and hardware configuration, improving adaptability beyond fixed commands. The guide explains how RepRap Firmware’s object model and meta commands enable conditional execution, reusable macros, and portability across machines. It recommends placing shared logic in macros, querying configured travel limits instead of hard-coding positions, calculating values rather than assuming settings, and commenting code clearly. These practices support reuse and sharing; the author presents them as opinions, not universal rules.",{"@graph":69,"@context":121},[70,84,104],{"@type":71,"itemListElement":72},"BreadcrumbList",[73,77,79,82],{"item":74,"name":75,"@type":76,"position":8},"https://docshare.wps.com","Home","ListItem",{"item":78,"name":9,"@type":76,"position":14},"https://docshare.wps.com/document/",{"item":80,"name":30,"@type":76,"position":81},"https://docshare.wps.com/document/technology/",3,{"item":83,"name":65,"@type":76,"position":19},"https://docshare.wps.com/document/1714641996091-conditional-g-code-best-practice/788085/",{"url":83,"name":65,"@type":85,"image":86,"author":91,"headline":65,"publisher":94,"fileFormat":97,"inLanguage":63,"description":67,"dateModified":98,"datePublished":98,"encodingFormat":97,"isAccessibleForFree":99,"interactionStatistic":100},"DigitalDocument",{"url":87,"@type":88,"width":89,"height":90},"https://docshare.wps.com/thumbnails/1714641996091-conditional-g-code-best-practice/788085.png","ImageObject",300,407,{"name":92,"@type":93},"Asher","Person",{"url":74,"name":95,"@type":96},"DocShare","Organization","application/pdf","2026-12-05",true,{"@type":101,"interactionType":102,"userInteractionCount":8},"InteractionCounter",{"@type":103},"ViewAction",{"@type":105,"mainEntity":106},"FAQPage",[107,113,117],{"name":108,"@type":109,"acceptedAnswer":110},"What does conditional G-code enable?","Question",{"text":111,"@type":112},"It allows commands to respond to firmware and hardware data, supporting different actions based on the machine’s current configuration or state.","Answer",{"name":114,"@type":109,"acceptedAnswer":115},"How can the RepRap object model support adaptable G-code?",{"text":116,"@type":112},"Its hierarchical data can be queried during execution, allowing values such as axis travel limits and positions to inform commands.",{"name":118,"@type":109,"acceptedAnswer":119},"What practices does the guide recommend for shared G-code?",{"text":120,"@type":112},"It recommends putting reusable code in macros, avoiding assumptions about machine configuration, using calculated values, and adding clear comments.","https://schema.org",{"og:url":83,"og:type":123,"og:title":65,"og:site_name":95,"og:description":67},"article",{"robots":125,"canonical":83},"index,follow",{"doc_id":127,"site_id":62},788085,1796475832,{"code":4,"msg":5,"data":130},{"doc_id":127,"user_id":131,"nickname":92,"user_avatar":132,"doc_module":4,"category_id":29,"category_name":30,"doc_title":65,"doc_description":67,"doc_content":133,"file_id":134,"file_url":135,"file_type":136,"file_size":137,"view_count":8,"is_deleted":4,"is_public":8,"is_downloadable":8,"audit_status":8,"page_count":39,"language":138,"language_code":63,"site_id":62,"html_lang":63,"table_of_contents":139,"faqs":140,"seo_title":141,"seo_description":67,"update_tm":128,"read_time":46,"preview_page_count":19,"preview_urls":142},687197207639,"https://ap-avatar.wpscdn.com/davatar_a8503ba1806abce46bf441b54a3ca4cd","Conditional G Code “best practice”  \nThis tutorial should be read in conjunction with the information provided by the Duet 3D wiki and in particular the sections on G Code [https://docs.duet3d.com/User_manual/Reference/Gcodes](https://docs.duet3d.com/User_manual/Reference/Gcodes)  \nReprap Firmware Object Model [https://docs.duet3d.com/en/User_manual/RepRapFirmware/Object_Model](https://docs.duet3d.com/en/User_manual/RepRapFirmware/Object_Model)  \nG-Code Meta Commands [https://docs.duet3d.com/User_manual/Reference/Gcode_meta_commands](https://docs.duet3d.com/User_manual/Reference/Gcode_meta_commands)  \nWhilst the subject of this page is \"best practice\" when writing conditional G Code, the author does not claim that the contents are in fact \"best practice\"  \nRather it is presented to demonstrate that there are many possible configurations spanning many types of applications. Therefore, if one is planning on creating conditional g-code (especially if those files are to be shared), then consideration should be given to making the code work as expected with minimum modification by as many people as possible.  \nG-Code is a well-known format designed to provide movement and other instructions to machines such as 3D printers, CNC cutting machines, milling machines etc.  \nIn the realms of 3D printing it is typically created a \"slicer\" and transferred to the printer for execution on a line by line basis.  \nThe machine will try to execute the command given regardless of circumstances or limitations.  \nThis makes G-Code almost universally usable only on the machine for which it was created, or other machines which are configured in exactly the same way. Likewise, there is little to no ability to \"react\" to variable circumstances during the execution of the code.  \nConditional G-Code provides the facility to carry out different commands based on data retrieved from the firmware and configured hardware.  \nThis data may be in the form of axis positions, temperatures, or any other information available through the RepRap Firmware object model.  \nThe object model is a hierarchical structure which contains \"objects\" to which values are assigned by the firmware.  \nThese objects may be queried during the execution of a G-Code file and the values returned can determine the path of the G-Code from that point.  \nThis provides a very powerful tool which allows for not only the ability to carry out jobs which may not have been previously possible, but also to compartmentalize code into \"macros\" or \"sub-programs\" which can be executed (or not) based on the information gathered from the object model. Furthermore it allows the creation of G-Code which is portable across machines of varying configurations and sizes.  \nIn order to take advantage of the power of conditional G-Code requires the user to follow certain programming rules, which include the use of correct syntax and structure. Additionally, \"best practice\" requires the user to (wherever possible), not make assumptions about the configuration of the machine that the code will run on.  \nInstead, you should try to replace any hard-coded values with calculated values.  \nAll code should also be heavily commented in order that anyone else who may look to use it can easily follow the intention of the author.  \nThe \"conduit\" between the G-Code file and the object model are the G-Code Meta Commands.  \nThese are essentially a subset of the C++ programming language which provides for code flow that is not necessarily sequential and allows the firmware to recognize and parse the returned data into values that would otherwise need to be hard coded.  \nThe object model has a hierarchical structure which can be \"drilled down\" upon to access various data that may be common to different parts of the machine. For example in a typical 3 axis machine, all axes have a \"current position\" which is unique to that axis.  \nHowever the \"path\" to that position can be represented in a common manner.  \nmove.axes[\"n\"].machineP","cbCaiv4EpXbHVzXC","https://ap.wps.com/l/cbCaiv4EpXbHVzXC","pdf",134784,"English","# Conditional G-code overview\n## Firmware data and machine adaptability\n# Object model and meta commands\n## Querying machine properties\n# Recommended practices\n## Reusable macros\n## Machine-independent positioning\n## Calculated values and comments","[{\"question\":\"What does conditional G-code enable?\",\"answer\":\"It allows commands to respond to firmware and hardware data, supporting different actions based on the machine’s current configuration or state.\"},{\"question\":\"How can the RepRap object model support adaptable G-code?\",\"answer\":\"Its hierarchical data can be queried during execution, allowing values such as axis travel limits and positions to inform commands.\"},{\"question\":\"What practices does the guide recommend for shared G-code?\",\"answer\":\"It recommends putting reusable code in macros, avoiding assumptions about machine configuration, using calculated values, and adding clear comments.\"}]","1714641996091 - Conditional G Code - Best Practice | PDF",[143,147,150,154],{"page_no":8,"url":144,"width":145,"height":146},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-12-05/7314f651fd19189916741b034805e72e.webp",983,694,{"page_no":14,"url":148,"width":149,"height":146},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-12-05/58e44ecd4439a41532bd049f96b0f9ca.webp",982,{"page_no":81,"url":151,"width":152,"height":153},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-12-05/b64f212a0c6c10e4970c6f54006ab23a.webp",981,693,{"page_no":19,"url":155,"width":156,"height":157},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-12-05/042b5667c4049ddffa5e1c233ce4860c.webp",980,692,{"list":159,"token":66},[160,166,172,179,185,192,198,203,209,215],{"doc_id":161,"doc_title":162,"file_type":136,"home_preview_img_url":163,"slug":164,"view_count":8,"category_name":30,"create_tm":165},788088,"3D Platform WorkSeries Quick Reference Guide - 200, 300 & 400 Series","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230058280696/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796587079&Signature=Q%2BW5NafKQJJtacoGizEqMvpS0uc%3D","3d-platform-workseries-quick-reference-guide-200-300-400-series",1796475842,{"doc_id":167,"doc_title":168,"file_type":136,"home_preview_img_url":169,"slug":170,"view_count":56,"category_name":30,"create_tm":171},348349,"Visual Studio Shortcuts 2021 - keyboard shortcuts guide","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229911610966/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796587079&Signature=mz64CSZeoyHucd8sBefsTzxYZmY%3D","visual-studio-shortcuts-2021-keyboard-shortcuts-guide",1790072538,{"doc_id":173,"doc_title":174,"file_type":136,"home_preview_img_url":175,"slug":176,"view_count":177,"category_name":30,"create_tm":178},733003,"Claude Code MCP Integration - Connect Your AI to Every Tool You Use","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230031415110/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796587079&Signature=i1%2FB4hsrkTJkt8g0Hb6Q1xg7%2Bx0%3D","claude-code-mcp-integration-connect-your-ai-to-every-tool-you-use",11,1795383257,{"doc_id":180,"doc_title":181,"file_type":136,"home_preview_img_url":182,"slug":183,"view_count":39,"category_name":30,"create_tm":184},696688,"MPLAB Harmony Integrated Software Framework - v1.11 - Overview","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230009773866/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796587079&Signature=0lOlZmDmefZXf9%2BjLZfSJkbllCw%3D","mplab-harmony-integrated-software-framework-v111-overview",1794434390,{"doc_id":186,"doc_title":187,"file_type":136,"home_preview_img_url":188,"slug":189,"view_count":190,"category_name":30,"create_tm":191},348347,"Visual Studio - Keyboard shortcuts - Code editing","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229911292363/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796587079&Signature=yA%2FXGSC2SvrHBRufmnoxm8SmCcE%3D","visual-studio-keyboard-shortcuts-code-editing",18,1790072536,{"doc_id":193,"doc_title":194,"file_type":136,"home_preview_img_url":195,"slug":196,"view_count":14,"category_name":30,"create_tm":197},786424,"URC-CCP-MX350 - Owner Manual","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230057391312/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796587079&Signature=OLosQnKf66GEg4RO99%2BCx1mKwxA%3D","urc-ccp-mx350-owner-manual",1796426566,{"doc_id":199,"doc_title":200,"file_type":136,"home_preview_img_url":201,"slug":200,"view_count":8,"category_name":30,"create_tm":202},787798,"95style","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230058185224/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796587079&Signature=7TjixSpZOVQWGbEgkR0QDlCQyd8%3D",1796468494,{"doc_id":204,"doc_title":205,"file_type":136,"home_preview_img_url":206,"slug":207,"view_count":39,"category_name":30,"create_tm":208},672939,"MPLAB Harmony 3 - Integrated Software Framework - Advanced and Easy-to-Use Embedded Software Solution","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229990229815/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796587079&Signature=D9pAyAKzmreVikxqlCQcwKbFpBE%3D","mplab-harmony-3-integrated-software-framework-advanced-and-easy-to-use-embedded-software-solution",1793615633,{"doc_id":210,"doc_title":211,"file_type":136,"home_preview_img_url":212,"slug":213,"view_count":44,"category_name":30,"create_tm":214},689395,"Actuarial symbols of life contingencies and financial mathematics","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230001309928/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796587079&Signature=Y2e4WOKMGwo9Lle21eJiyH%2BpO%2B0%3D","actuarial-symbols-of-life-contingencies-and-financial-mathematics",1794106654,{"doc_id":216,"doc_title":217,"file_type":136,"home_preview_img_url":218,"slug":219,"view_count":41,"category_name":30,"create_tm":220},81579,"Programming over Thinking: Efficient and Robust Multi-Constraint Planning","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229808627462/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796587079&Signature=J082M8qotY9gL7AZf7cis8HTnv4%3D","programming-over-thinking-efficient-and-robust-multi-constraint-planning",1784174444]