I see that there is a way to get units SUModelGetUnits from the model. But no method to Set the units for the model/file.
So, is it possible to set the units?
If yes, what is the method or is there any other indirect way - such that the new file gets saved with "Millimeters" units?
Note:This question has been posted earlier as part of this thread http://sketchucation.com/forums/viewtopic.php?f=180%26amp;t=57909.
Since this is a different question from the original thread I have added it separately.
Yes, it is possible to set the units using the SketchUp C API. You just need to use the UnitsOptions options manager to set the LengthFormat and the LengthUnit.
The UnitsOptions/LengthFormat value for Decimal is 0.
The UnitsOptions/LengthUnit value for millimeters is 2.
Here's some sample code that sets these values:
// Get the options manager
SUOptionsManagerRef options_manager = SU_INVALID;
SUModelGetOptionsManager(my_model, &options_manager);
// Get the UnitsOptions options provider
SUOptionsProviderRef options_provider = SU_INVALID;
SUOptionsManagerGetOptionsProviderByName(options_manager, "UnitsOptions",
&options_provider);
// Make a new typed value with value for mm
SUTypedValueRef typed_value = SU_INVALID;
SUTypedValueCreate(&typed_value);
SUTypedValueSetInt32(typed_value, 2);
// Set the value for LengthFormat to Decimal
SUTypedValueSetInt32(typed_value, 0);
SUOptionsProviderSetValue(options_provider, "LengthFormat", typed_value);
// Set the value for LengthUnit to mm
SUTypedValueSetInt32(typed_value, 2);
SUOptionsProviderSetValue(options_provider, "LengthUnit", typed_value);
You can find the full documentation for options provider here, which includes the breakdown of the various options providers, options, and values available.
Hope this helps.
Paul
Related
Good afternoon,
We´ve been working on an animal model (skull) applying a series of forces and evaluating the resultant stresses in Abaqus. We got some of those beautiful and colourful (blue-to-red) contour-plots. Now, we´d like to obtain a similar image but coloured by a new matrix, which will be the result of some methematical transformations.
So, how can I extract the data matrix used to set those colour patterns (I guess with X-, Y-, Z-, and von Mises-values or so), apply my transformation, and replot the data to get a new (comparable) figure with the new values?
Thanks a lot and have a great day!
I've never done it myself but I know that this is possible. You can start with the documentation (e.g. here and here).
After experimenting using GUI you can check out the corresponding python code which should be automatically recorded in the abaqus.rpy file at your working directory (or at C:\temp). Working it trhough you could get something like:
myodb = session.openOdb('my_fem.odb') # or alternatively `session.odbs['my_fem.odb']` if it is already loaded into the session
# Define a temporary step for accessing your transformed output
tempStep = myodb.Step(name='TempStep', description='', domain=TIME, timePeriod=1.0)
# Define a temporary frame to storeyour transformed output
tempFrame = tempStep.Frame(frameId=0, frameValue=0.0, description='TempFrame')
# Define a new field output
s1f2_S = myodb.steps['Step-1'].frames[2].fieldOutputs['S'] # Stress tensor at the second frame of the 'Step-1' step
s1f1_S = myodb.steps['Step-1'].frames[1].fieldOutputs['S'] # Stress tensor at the first frame of the 'Step-1' step
tmpField = s1f2_S - s1f1_S
userField = tempFrame.FieldOutput(
name='Field-1', description='s1f2_S - s1f1_S', field=tmpField
)
Now, to display your new Field Output using python you can do the following:
session.viewports['Viewport: 1'].odbDisplay.setFrame(
step='TempStep', frame=0
)
For more information on used methods and objects, you can consult with the documentation "Abaqus Scripting Reference Guide":
Step(): Odb commands -> OdbStep object -> Step();
Frame(): Odb commands -> OdbFrame object -> Frame();
FieldOutput object: Odb commands -> FieldOutput object;
I am working with the STM8AF5286UDY and am trying to set up a CAN interface.
For programming, I use the standard peripheral library. At the moment, my CAN interface works fine. The only thing, which does not work, is filtering.
I use extended IDs and want to get all IDs from 0x18FEC100 to 0x18FEC999.
My code looks as follows:
/* CAN filter init */
CAN_FilterNumber = CAN_FilterNumber_0;
CAN_FilterActivation = ENABLE;
CAN_FilterMode = CAN_FilterMode_IdMask;
CAN_FilterScale = CAN_FilterScale_32Bit;
CAN_FilterID1=0x18FEC101;
CAN_FilterID2=0;
CAN_FilterID3=0;
CAN_FilterID4=0;
CAN_FilterIDMask1=0x1FFFF000;
CAN_FilterIDMask2=0;
CAN_FilterIDMask3=0;
CAN_FilterIDMask4=0;
CAN_FilterInit(CAN_FilterNumber, CAN_FilterActivation, CAN_FilterMode,
CAN_FilterScale,CAN_FilterID1, CAN_FilterID2, CAN_FilterID3,
CAN_FilterID4,CAN_FilterIDMask1, CAN_FilterIDMask2,
CAN_FilterIDMask3, CAN_FilterIDMask4);
I would appreciate any help! Thank you!
EDIT: In my initial code, I forgot to include IDE and RTR at addressing. Also, in the library, each address and mask is an 8-bit value. Therefore, I have changed my code to the following:
/* CAN filter init */
CAN_FilterNumber = CAN_FilterNumber_2;
CAN_FilterActivation = ENABLE;
CAN_FilterMode = CAN_FilterMode_IdMask;
CAN_FilterScale = CAN_FilterScale_32Bit;
CAN_FilterID1=0xc7;
CAN_FilterID2=0xed;
CAN_FilterID3=0x02;
CAN_FilterID4=0x02;
CAN_FilterIDMask1=0xFF;
CAN_FilterIDMask2=0xE7;
CAN_FilterIDMask3=0xE0;
CAN_FilterIDMask4=0x00;
CAN_FilterInit(CAN_FilterNumber, CAN_FilterActivation, CAN_FilterMode,
CAN_FilterScale,CAN_FilterID1, CAN_FilterID2, CAN_FilterID3,
CAN_FilterID4,CAN_FilterIDMask1, CAN_FilterIDMask2,
CAN_FilterIDMask3, CAN_FilterIDMask4);
This filter works for the first 16-bit, so at using 0x18FEC101 it filters the 0x18FE. Somehow, it does not work for the other 16-bit.
In the library, the following code is used for writing the addresses and masks in the filter bank at 32-bit:
else if (CAN_FilterScale == CAN_FilterScale_32Bit)
{
CAN->Page.Filter.FR01 = CAN_FilterID1;
CAN->Page.Filter.FR02 = CAN_FilterID2;
CAN->Page.Filter.FR03 = CAN_FilterID3;
CAN->Page.Filter.FR04 = CAN_FilterID4;
CAN->Page.Filter.FR05 = CAN_FilterIDMask1;
CAN->Page.Filter.FR06 = CAN_FilterIDMask2;
CAN->Page.Filter.FR07 = CAN_FilterIDMask3;
CAN->Page.Filter.FR08 = CAN_FilterIDMask4;
}
Are there any ideas, what my mistake might be?
Thanks!
Mask filtering works bitwise. So you can't create a filter to accept values between 0x18FEC100 - 0x18FEC999. You need to think binary.
In the filter mask registers, 1 means "must match" and 0 means "don't care".
ID = 0x18FEC101 and Mask = 0x1FFFF000 means that it will accept values between 0x18FEC000 - 0x18FECFFF as the filter won't care the least significant 12 bits.
However, the process is further complicated by the bit arrangement of the hardware registers. Be aware that RTR & IDE bits are also included in the filter registers. I don't know if the standard peripheral library handles this but probably not. You probably need to manually arrange the bits to determine the correct register values. In the reference manual (RM0016), refer to Figure 148.
The code I posted (edited version) works now.
Turns out I had a problem calculating the addresses by hand.
Thank you #Tagli.
I have been searching for ar.js multimarkers tutorial or anything that explains about it. But all I can find is 2 examples, but no tutorials or explanations.
So far, I understand that it requires to learn the pattern or order of the markers, then it stores it in localStorage. This data is used later to display the image.
What I don't understand, is how this "learner" is implemented. Also, the learning process is only used once by the "creator", right? The output file should be stored and then served later when needed, not created from scratch at each person's phone or computer.
Any help is appreciated.
Since the question is mostly about the learner page, I'll try to break it down as much as i can:
1) You need to have an array of {type, URL} objects.
A sample of creating the default array is shown below (source code):
var markersControlsParameters = [
{
type : 'pattern',
patternUrl : 'examples/marker-training/examples/pattern-files/pattern-hiro.patt',
},
{
type : 'pattern',
patternUrl : 'examples/marker-training/examples/pattern-files/pattern-kanji.patt',
}]
2) You need to feed this to the 'learner' object.
By default the above object is being encoded into the url (source) and then decoded by the learner site. What is important, happens on the site:
for each object in the array, an ArMarkerControls object is created and stored:
// array.forEach(function(markerParams){
var markerRoot = new THREE.Group()
scene.add(markerRoot)
// create markerControls for our markerRoot
var markerControls = new THREEx.ArMarkerControls(arToolkitContext, markerRoot, markerParams)
subMarkersControls.push(markerControls)
The subMarkersControls is used to create the object used to do the learning. At long last:
var multiMarkerLearning = new THREEx.ArMultiMakersLearning(arToolkitContext, subMarkersControls)
The example learner site has multiple utility functions, but as far as i know, the most important here are the ArMultiMakersLearning members which can be used in the following order (or any other):
// this method resets previously collected statistics
multiMarkerLearning.resetStats()
// this member flag enables data collection
multiMarkerLearning.enabled = true
// this member flag stops data collection
multiMarkerLearning.enabled = false
// To obtain the 'learned' data, simply call .toJSON()
var jsonString = multiMarkerLearning.toJSON()
Thats all. If you store the jsonString as
localStorage.setItem('ARjsMultiMarkerFile', jsonString);
then it will be used as the default multimarker file later on. If you want a custom name or more areas - then you'll have to modify the name in the source code.
3) 2.1.4 debugUI
It seems that the debug UI is broken - the UI buttons do exist but are nowhere to be seen. A hot fix would be using the 'markersAreaEnabled' span style for the div
containing the buttons (see this source bit).
It's all in this glitch, you can find it under the phrase 'CHANGES HERE' in the arjs code.
I replaced my code where I was making a QnA dialog using new cognitiveservices.QnAMakerDialog constructor and I was able to pass extra key-value pair for example threshold, feedbackLib etc. with the code where I can use QnA in single dialog using
cognitiveservices.QnAMakerRecognizer.recognize(query, 'QnAhost', 'endpointKey key','Authorization', 3, 'intentname', function (error, results)
{
session.send(results.answers[0].answer);
// console.log(results);
});
}).triggerAction({
matches: 'intentname'
});
But I am not sure how can I add the threshold value and feedbackLib to the QnA. This way it is returning an answer even if the confidence score is very low.
Please help.
Thanks.
Vivek,
the constructor for QnAMakerRecognizer takes a set of IQnAMakerOptions. These are defined here
When you create your recognizer instance call the contructor like this:
var recognizer = new cognitiveservices.QnAMakerRecognizer({
knowledgeBaseId: 'set your kbid here',
authKey: 'set your authorization key here',
qnaThreshold: (This is a number) set your threshold value here,
feedbackLib: (This is a QnAMakerTool object) set your lib here
});
Hope this helps.
I have a simple filter.
var filter = ctx.createBiquadFilter();
filter.type = 'highpass';
filter.frequency.setValueAtTime(10,ctx.currentTime);
I would like to see its frequency response using getFrequencyResponse
window.setInterval(function() {
var frequencyHz = new Float32Array(1),
magResponse = new Float32Array(1),
phaseResponse = new Float32Array(1);
frequencyHz[0] = 10;
filter.getFrequencyResponse(frequencyHz,magResponse,phaseResponse);
console.log(magResponse);
},100);
I expect to see [0.9565200805664062] which is the correct response for 10Hz, but instead I see [0.0008162903832271695] which is the response for 350Hz, the default frequency value.
I can only get a sensible response if I manually set the value, whereas if I use param methods such as setValueAtTime, the filter response ignores them and spits out the default. In other words, getFrequencyResponse seems to only work if the filter values are set manually, preventing filter analysis when the values are set by automation. If this is true, this seems like more than a small problem with the api.
Someone please try something near to this, and if it works (doubtful) please post the code.
Actually, no, it should be taking effect, but because you're causing an instantaneous value change at the NEXT processing block (that's what ".currentTime" means), that change has not yet been processed - so you're seeing the default value. You should see, for example, getFrequencyResponse changes over time for a setLinearRamp.