How to Set/Get "Last Saved on" Information for a baseline using Aspose.Tasks - ms-project

I want to export data and create MsProject File using Aspose.Tasks. I am able to export data from my local db to project file successfully but while exporting Baseline information I am not able to find how to set "Last Saved on" information for the baseline. I am using below code to create and set baseline.
project.SetBaseline(BaselineType.Baseline, new Task[] { task });
var baselineType=BaselineType.Baseline;
TaskBaseline baseline = task.Baselines.FirstOrDefault(x =>
x.BaselineNumber.Equals(baselineType));
if (baseline != null)
{
if (!String.IsNullOrEmpty(baselineDto.Cost))
baseline.Cost = Convert.ToDecimal(baselineDto.Cost);
}
If Anyone has any idea how to Get/Set "Last Saved on" Information for a baseline, please share.
Thanks.
Bhupesh

I have observed your requirements and like to inform that we can only get Last Saved information using Aspose.Tasks. I have shared following sample code. This will help you to achieve your requirements.
var s = #"c:\test\baseline msp 2016.mpp"; Project p = new Project(s);
Console.WriteLine(p.GetBaselineSaveTime(BaselineType.Baseline));
Console.WriteLine(p.GetBaselineSaveTime(BaselineType.Baseline1));
Console.WriteLine(p.GetBaselineSaveTime(BaselineType.Baseline2));
I am working as Support developer/ Evangelist at Aspose.

Related

how to firebase ml vision storing each line to a variable

I'm currently trying to learn flutter and implement OCR with firebase ml vision, but currently I want to store the text read to a variable, what's the suggested approach?
For example I have a paper with
NAME
INFORMATION
Can I read the first line and store as String variable name and second line as information? How should I implement my for loop here?
Let's say I already imported the libraries, and I'm stuck here.
for (TextBlock block in visionText.blocks) {
for(n=0; n<block.lines.length; n++ )
{
name =
info =
}
}
Thanks in advance
In your scenario, assuming both name and information take one line each, I would do it the first way:
for (TextBlock block in visionText.blocks) {
name = block.lines[0];
info = block.lines[1];
}

Is there a way to extract the XYZ geometry data from a converted Revit model?

I'm creating a solution that converts a revit model to IFC file format using Autodesk Forge - Model Derivative API. This API hands me a JSON file with the hierarchy of the converted model, and a JSON file with all separate objects and their properties.
After converting the model I need to analyze specific properties from parts of the model. But not all information I need is stored in objects' properties. I also need to use XYZ coordinates of objects to get real results, but I believe the model derivative API doesn't generate XYZ data.
I've already searched all the properties of the objects to see if they contain any kind of data about their location in comparison to other objects, but they don't contain that information. I've searched for other ways to extract geometry/coordinates from Revit, but haven't found a real solution.
https://forge.autodesk.com/en/docs/model-derivative/v2/tutorials/extract-metadata-from-source-file/
In step 5 of this tutorial you can see the data that I have (the properties of each object).
There is no way to get the XYZ data from the Model Derivative API the way that you are hoping.
I'd also say that if you are looking to convert to IFC, there is already a conversion service for that in the Model Derivative API. But in case you really need a custom file format, here is how you could get XYZ, below.
There are two other options though that you can consider.
One, is to use the Design Automation for Revit API. You would be able to make an Addin that pulls the needed data from the headless Revit environment.
Another option is to launch a headless Forge Viewer and get the XYZ data of the model from there.
The headless viewer is a tutorial in the Viewer API documentation that you can check out. Here is the code from it (v6) for reference.
var viewerApp;
var options = {
env: 'AutodeskProduction',
accessToken: ''
};
var documentId = 'urn:<YOUR_URN_ID>';
Autodesk.Viewing.Initializer(options, onInitialized);
function onInitialized() {
viewerApp = new Autodesk.Viewing.ViewingApplication('MyViewerDiv');
viewerApp.registerViewer(viewerApp.k3D, Autodesk.Viewing.Viewer3D);
viewerApp.loadDocument(documentId, onDocumentLoaded);
}
function onDocumentLoaded(lmvDoc) {
var modelNodes = viewerApp.bubble.search(av.BubbleNode.MODEL_NODE); // 3D designs
var sheetNodes = viewerApp.bubble.search(av.BubbleNode.SHEET_NODE); // 2D designs
var allNodes = modelNodes.concat(sheetNodes);
if (allNodes.length) {
viewerApp.selectItem(allNodes[0].data);
if (allNodes.length === 1){
alert('This tutorial works best with documents with more than one viewable!');
}
} else {
alert('There are no viewables for the provided URN!');
}
}
Once you're accessing the viewer, here is some code that you can get the bounding box of an element or elements by dbIds that I've used successfully.
/**
* Uses dbId element fragments to build boundingbox of element
* #param {Array<number>} dbIds dbIds of element to find boundingBox
* #return {THREE.Box3} dbId elements bounding box
*/
getBoundingBox(dbIds) {
const totalBox = new THREE.Box3();
dbIds.forEach((dbId) => {
const fragBox = new THREE.Box3();
const fragIds = [];
const instanceTree = viewer3D.model.getInstanceTree();
instanceTree.enumNodeFragments(dbId, function(fragId) {
fragIds.push(fragId);
});
const fragList = viewer3D.model.getFragmentList();
fragIds.forEach(function(fragId) {
fragList.getWorldBounds(fragId, fragBox);
totalBox.union(fragBox);
});
});
return totalBox;
}
From this BoundingBox which is a THREE.Box3 object, you can get some XYZ information about the elements. Also, there is code here using the 'fragments' that will allow you to get different element geometry more specifically if that is more useful for the XYZ you need to define.

Firebase Analytics: combine paramaters/values in console-view

I'm new to Firebase (and stackoverflow) and have a question:
Is it possible in the console view for firebase to combine the data? What I want to achieve is that when in "parameter_name" I select for example the "scene_interaction" and automatically the "scene_name" displays only the values for the "scene_interaction"-parameter (and ignoring "button_pressed" and "main"). See screenshot for this:
The event is logged as follow:
parameterEntry = new Firebase.Analytics.Parameter[]
{
new Firebase.Analytics.Parameter("parameter_name", parameterList[i].parameterName),
new Firebase.Analytics.Parameter("action_value", parameterList[i].value),
new Firebase.Analytics.Parameter("action_type", parameterList[i].type),
new Firebase.Analytics.Parameter("scene_name", parameterList[i].scene),
new Firebase.Analytics.Parameter("scene_type", parameterList[i].scene_type)
};
}
Firebase.Analytics.FirebaseAnalytics.LogEvent(eventName, parameterEntry);
I hope someone can help me. Preferably without the use of BigQuery.

Saving google sheets data into Firebase using Google Apps script

I'm trying to have my google sheets synced with my firebase database. I'm not very experienced with javaScript, so is it possible using the below method? The idea is that it would automatically sync every time a new row gets created/updated/deleted. I know that I need the script files but not sure how to import them in the .gs file, so that's why it's in the html.
Many thanks!
translate.gs
function saveToFirebase() {
var config = {
apiKey: "MY_API_KEY",
authDomain: "MY_DOMAIN.firebaseapp.com",
databaseURL: "MY_DOMAIN.firebaseio.com",
projectId: "MY_DOMAIN",
storageBucket: "MY_DOMAIN.appspot.com",
messagingSenderId: "MESSAGE_ID"
};
firebase.initializeApp(config);
var database = firebase.database();
database.ref('food/' + MY_USER_UID).set({
name: "pizza funghi",
});
}
sidebar.html
<!DOCTYPE html>
<html>
<head>
<script src="https://www.gstatic.com/firebasejs/4.12.0/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/4.12.0/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/4.12.0/firebase-database.js"></script>
</head>
<body>
</body>
</html>
There is a third-party libarary which integrates with Firebase's REST API. If you're comfortable using it, this becomes pretty straightforward.
First we'll need to create a tab to track changes. We need the identity of those who make changes, so we have to break this into two parts - a simple onEdit trigger which runs as the modifying user, and an installable trigger which I'll call uploadChanges. The latter is what talks to Firebase.
Create a tab called changes
Add a frozen row with the following headers:
Uploaded
User
Value
Install the third party Firebase library
Begin by clicking Resources > Libraries in the script editor, then pasting MYeP8ZEEt1ylVDxS7uyg9plDOcoke7-2l in the "Find a Library" box. Hit Save.
Opt for stability by choosing the latest public release, or choose the latest release (I chose latest while writing this).
Click OK
Now would be a good time to peruse the reference docs so you know what I'm up to in the below instructions :-)
Set up security (I'm assuming you want this script to run as you)
Make your Google account (which runs the script) be at least an Editor for your Firebase project.
Set the appropriate authorization scopes for your App Script project:
Go to File > Project Properties > Scopes in the App Script editor
Select View > Show manifest file (the manifest file is usually hidden by default)
Add https://www.googleapis.com/auth/userinfo.email and https://www.googleapis.com/auth/firebase.database to the oauthScopes array (add it if it's not already there)
Save the manifest file. Next time you run the script you'll get a pop-up asking about permissions.
The equivalent of your translate.gs above, which always just sets your food to 'pizza funghi`, would look like this:
function saveToFirebase() {
var dbUrl = "MY_DOMAIN.firebaseapp.com"; // Set appropriately
var token = ScriptApp.getOAuthToken(); // Depends on security setup above
var firebase = FirebaseApp.getDatabaseByUrl(dbUrl, token);
newData = {
name: "pizza funghi",
};
firebase.setData('food/' + MY_USER_UID, newData);
}
But you said you wanted to update Firebase on every save. To do this you really just want to rip off one of the various onEdit tutorials floating around the net. The resulting onEdit should look something like this:
function onEdit(e) {
// First get stuff about the edit.
// This approach only gets the top left cell of a multi-cell edit.
var editRange = e.range; // The edited range
var newValue = editRange.getValue();
// Next, who is the editor? Remove the `split` for full email.
var username = Session.getActiveUser().getEmail().split('#')[0];
if (username == '') {
username = SOME_REASONABLE_DEFAULT; // Or give up if you wish
}
// Finally save the change
SpreadsheetApp.getActiveSpreadsheet()
.getSheetByName('changes')
.appendRow([false, username, newValue]);
}
function uploadChanges() {
// Attach to Firebase
var dbUrl = "MY_DOMAIN.firebaseapp.com"; // Set appropriately
var token = ScriptApp.getOAuthToken(); // Depends on security setup above
var firebase = FirebaseApp.getDatabaseByUrl(dbUrl, token);
// Get content of changes tab
var changeSheet = SpreadsheetApp.getActiveSpreadsheet()
.getSheetByName('changes');
var changeData = changeSheet.getDataRange()
.getValues();
// Upload all new-to-us changes
for (var i = 1; i < changeData.length; i++) {
if (changeData[i][0]) {
continue; // We already uploaded this one
}
changeData[i][0] = true; // Optimistically assume we'll succeed
var newData = {
name: changeData[i][2]
};
var username = changeData[i][1];
firebase.setData('food/' + username, newData);
}
// Blanket update of change-data sheet to update upload status
changeSheet.getRange(1, 1, changeData.length, changeData[0].length)
.setValues(changeData);
}
Lastly, set up some triggers.
Choose Edit > Current Project's Triggers in the script editor
Add a new trigger for onEdit
Choose onEdit from the leftmost Run dropdown
Choose From spreadsheet in the Events dropdown
Then choose On edit in the rightmost dropdown
Add a new trigger for uploadChanges
Choose uploadChanges from the leftmost Run dropdown
Choose Time-driven from the Run dropdown
Set up a schedule that's appropriate to your needs
EDIT: My original script had you doing everything in onEdit, which tehhowch correctly points out won't work since we're talking to another service. I've updated to stage to a "changes" tab which I include in setup. My new approach maintains a perpetual record of old uploads; for performance you might instead choose to just clear the changes sheet once you've done the upload.

Can't put data from a Meteor collection into an array

I'm learning Meteor and I was trying to pass the result of a Collection.find() into and array (using a variable) and the simpler code I have is (in a file that is in the root):
CalEvents = new Mongo.Collection('calevents'); //creating a collection
/*------------------------- Populating the database with dummy data-------*/
if (Meteor.isServer) {
Meteor.startup(function () {
if (CalEvents.find().count() === 0) {
CalEvents.insert({
title: "Initial room",
start: '2010-02-02'
});
}
});
}
/*--------------- Creating an array from the collection-----------------*/
events = [];
calEvents = CalEvents.find({});
calEvents.forEach(function(evt){
events.push({
title: evt.title,
start: evt.start,
})
});
The page has nothing to show but using the console I can see (CalEvents.find().fetch()) that I have data in my database but the "events" variable is empty...
I can't understand why because I tried several other things such as changing file names and moving code to guarantee the proper order.
And I already tried to use CalEvents.find().fetch() to create an array an put the result into a variable but I'm not able to do it...
Does anyone know what's so simple that I'm missing?...
Do you use autosubscribe?
You probably need to make sure the sbscription is ready. See Meteor: How can I tell when the database is ready? and Displaying loader while meteor collection loads.
The reason you do see CalEvents.find().fetch() returning items in the console is that by the time you make that call, the subscription is ready. But in your events = []; ... code (which I assume is in a file under the client directory, you might have assumed that the subscription data has arrived when in fact it has not.
A useful debugging tool is Chrome's device mode ("phone" icon near the search icon in DevTools), which lets you simulate slow networks (e.g. GPRS, with 500ms delay for every request).

Resources