SWBDesign Posted February 3, 2016 Share Posted February 3, 2016 I have question for the Ruby “Black Belts” in the group. Could I use Ruby to access information from an external DB and pull across the information into Chief, displaying the data via text macros? Background: We currently use Filemaker Pro for our CRM. Client details, project details & task administration are all done from inside the database. As I have a pet hate for entering the same information any more times than once what I would like to be able to do is pull across the information contained in the DB, information such as: -Project Name -Project Address -Project Number -Copyright -Project start date. -Client Name My inital thinking is to create text macros for each required field and then have Ruby either access the DB or read from a file output from the DB. I can definitely create a script for the Database to automatically create an output file & locate it within the project file structure, but I have literally know idea how or if this can even be connected to Ruby and then brought into Chief. Comments from those fluent with Ruby programming appreciated Link to comment Share on other sites More sharing options...
GerryT Posted February 3, 2016 Share Posted February 3, 2016 Ruby in Chief can only read a text file, which you can do using the Ruby IO or FILE class. (google ruby File class) Natively, Ruby can also read any Sqlite DB (which is used by Chief) but Chief has chosen to not include that feature in the version of Ruby that they created. I believe Joe has a macro to do as you asked but it's simple enough to do yourself. Do some research on File.open in Ruby and if you have any trouble, just e-mail me and I'll walk you through it. Just create a CSV file and everything else is just one/two lines of code., However you can NOT write to the Chief data fields such as Project Name , etc. since ruby macros in Chief only read attributes. If you input that info, it must be located/stored in ruby's global memory ($...) which you can then retrieve directly via another macro and print that to a text box. Link to comment Share on other sites More sharing options...
Joe_Carrick Posted February 3, 2016 Share Posted February 3, 2016 Steve, If you can write a script to output that information to a text file (preferably as individual lines for each piece of information) located in the Plan Folder, I can write a macro for you to store it in a global hash table along with macros to display each one. I actually have a macro package that does this for the Project Info and various Consultants. What you indicate above is just slightly different (some extra pieces of info) but basically the same. Link to comment Share on other sites More sharing options...
KirkClemons Posted February 3, 2016 Share Posted February 3, 2016 There are already macros in Chief to pull and print this information, you just need to add the information to the project: Link to comment Share on other sites More sharing options...
Joe_Carrick Posted February 3, 2016 Share Posted February 3, 2016 Kirk, Client is not the same as Project. The Client might be a Builder but the Project could be a specific job. Also, if you look carefully, Steve has some data that is not in the Client Info. Additionally, there is no way for us to insert external data directly into the "Client Info" other than using Copy/Paste. For every job, I also have a series of consultants: Structural Surveyor Geologist Electrical Title 24 None of that is provided for by Chief so I have to maintain external files which can be read to add that to my Layout. Link to comment Share on other sites More sharing options...
SWBDesign Posted February 3, 2016 Author Share Posted February 3, 2016 Joe, Thanks for the offer, I'll do some work at this end writing the export script from the Database. At this stage it is looking like the output file will be .csv or .tab, if that's the case i won't be able to have the data on separate lines, hope that's not a problem. Will be in touch. Link to comment Share on other sites More sharing options...
Joe_Carrick Posted February 3, 2016 Share Posted February 3, 2016 Joe, Thanks for the offer, I'll do some work at this end writing the export script from the Database. At this stage it is looking like the output file will be .csv or .tab, if that's the case i won't be able to have the data on separate lines, hope that's not a problem. Will be in touch. The best format is .txt But Ruby is good at manipulating strings. As long as I know what the delimiters are when I read in the file - no problem. Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now