Is there a way to define a named parameter based on a dimension in a sketch? - fusion360

I'd like to use a sketch to "compute" the correct sizing of a parameter, and then use that parameter in other sketches. If it were a simple value to figure out I would define it directly as a user parameter, and then use it in both my sketches.
The only way I have currently is to overlay the sketches and create equality constraints, but that doesn't feel as clear as having a named parameter
Any thoughts?
thanks!

Every dimension, when created, is matched to the equivalent of a variable name (d0, d1, d2...). These are called Model Parameters and they are autogenerated by fusion360. After you have created the dimension that you want other dimensions to refer to hover your mouse over it. A small window should show you the name you can use to refer to that variable in the format: d1: 40 mm.
If you want to create your own parameters I'd recommend watching this video and this video.

Related

Sikulix : Compare a image and a screen of website

I use sikulix and I want to check if a region of a website is red or green.
So I have taken a picture of the part of the website when is red (negatif.png)
A another region for the check of the color. But it doesn't work.
img_negatif = "negatif.png"
profit = Region(1342,212,175,21)
if profit == img_negatif:
click(Location(3406,1420))
else:
click(Location(23,1420))
Everytime sikulix take the else.
You cannot compare regions strictly by color. You can see my answer here (this is from years back but I think it's still relevant).
Sikuli compares the regions with pixel to pixel precision (you can set a similarity level if the images slightly differ but that's not the case). So having selected an area with just color and no other pattern will not work.
Wait for 3 second for negatif and if appear ...
if exists(img_negatif, 3):
click(Location(3406,1420))
else:
click(Location(23,1420))
You can search a region for color with Brobot, an open-source automation framework for Java that wraps SikuliX functions. Brobot references OpenCV for its color functionality. The Brobot documentation gives more detailed information on the framework. Additionally, there is a page in the documentation on color searches. For a summary of Brobot's color functionality, you can read this StackOverflow answer.
Finding the Red Region
public Matches find() {
ActionOptions actionOptions = new ActionOptions.Builder()
.setAction(FIND)
.setFind(COLOR)
.build();
return action.perform(actionOptions, redRegionState.getRedArea());
}
Elements of this code block:
Matches, the return value, holds information about the individual matches and the action.
ActionOptions is used to configure the action. Here, we tell it we want a FIND operation and we want to find by COLOR.
The Action class is the Brobot class that performs actions. The result of an action is always a Matches object. The function action.perform requires as parameters (1) the action configuration and (2) the object(s) to act on. Here, we pass in our actionOptions variable and our image.
The image “negatif.png” is stored in a Brobot variable called redArea, located in the state RedRegionState, and called with redRegionState.getRedArea().
The average pixel color of all pixels in “negatif.png” is calculated and this color is searched for on-screen.
The classes Action and RedRegionState are passed to this class with dependency injection.
The Red Image
You could also declare the Brobot variable containing “negatif.png” locally but one of the main benefits of Brobot is its ability to simulate the environment and test code with mock runs. This requires creating states that group associated images. Inside the state, the image definition would look like this:
#Component
#Getter
public class RedRegionState {
…
private StateImageObject redArea = new StateImageObject.Builder()
.withImage("negatif.png")
.withSearchRegion(1342,212,175,21)
.build();
…
}
Including a search region in the image variable means that the image will be searched for in this region on-screen unless a search region is added to the action configuration (the ActionOptions variable).
Clicking after Searching
public void click() {
int x = find().isSuccess() ? 3406 : 23;
action.perform(CLICK, new Location(x, 1420).asObjectCollection());
}
Elements of this code block:
Each action (FIND, CLICK, DEFINE, etc.) has its own success condition, and the result is stored in the Matches variable. It can be called with the boolean function .isSuccess().
As above, action.perform takes as parameters the action configuration and the object(s) to act on.
Usually an ActionOptions variable is required for the first parameter. However, an enum representing the action (here, CLICK) can be passed directly if you wish to use the action's default options.
The second parameter usually takes an ObjectCollection variable. In some cases, as with the image redArea, the object can be passed directly. Here, the object acted on, a Location, is converted to a singleton ObjectCollection and passed as the second parameter.
When building a more complex automation application, it would make sense to include the Location variables as well in states. Most likely, the Location at (3406, 23) would be in RedRegionState, as this Location has a special meaning when redArea is visible.
Disclaimer: I'm the developer of Brobot. It's free and open source.

Pass the current control to code

I wonder if there is a way to pass the current control to own code, either to code embedded on the report or to code linked in from another assembly.
Reason is I need to do some custom control drawing (the control will therefore be an image) and it would be handy to query the image size from the control that called.
So instead of putting
=Code.DrawOwn(200, 200, ... )
I'd like to use
=Code.DrawOwn(Me, ... )
or
=Code.DrawOwn(ReportingItems!Image1, ... )
Any way to do that? I fail on defining DrawOwn so that it accepts a parameter of "Control" or "Image" as none of these types seem to exist.

Can two buttons with the same class instance act differently in Flash?

Say I have this specific button class in Flash called cont_button and it's supposed to be used to break out of a loop, but I want to use the class more than once. Is there a way to give every instance of this class some kind of parameter so that it knows which frame it nees to go to?
Example:
I have an instance of cont_button on frame 200 and there's a loop between 200 and 210. This cont_button executes a gotoAndPlay(211). But later on I have another instance of the button on frame 315 and a loop between 315 and 325. Is there a way to make it so each instance knows which frame it specifically needs to go to via the use of a variable? Or am I going to have to make an actionscript file for each individual one?
Pretty new to ActionScript so I appreciate the help and if there are good coding references to AS3 you guys recommend, I'll gladly look those over.
Sure, this is possible. One way you can do this is make the frame numbers class variables and when the button is clicked, they reference whatever value is stored in them, rather then hardcoded numbers. To get a better idea, can you post the relevant parts of your button class?
As you say, you need to pass a parameter to each instance of the button. There are lots of different ways you could do this, but I'd be tempted to just do it via the instance names.
You could name each button loopBreakTo211, loopBreakTo326 and so on, then in your button's class have:
var breakFrame:Number = Number(name.replace("loopBreakTo", ""));
(parent as MovieClip).gotoAndPlay(breakFrame);
Admittedly that's not a very robust way of doing it (for example, it will break if a button is named incorrectly and breakFrame ends up as NaN, so you might want to add a check for that), but it keeps the parameter together with the instance instead of in the timeline somewhere.

Storing Multiple Images In A Variable With Action Script 3 In Flash Builder 4.5

I have a flash assignment that I need help getting started, any advice would be greatly appreciated. The assignment is to create an application for playing a card game, I have to create an MXML component that has two variables, one variable stores the image of the back of a playing card, the other variable has t store all 52 options of a front facing card (the second variable will store over 50 images).
I've written the variable for the back of the card image like this:
public var backOfCard:Image = new Image();
backofCard.source = 'asset/backImage';
However I get an undefined variable error (1120: Access of undefined propery variable img1), I feel like there's something small that I'm missing here, but I was wondering if anyone could spot it.
I'd also like to know if I should use the same method for each jpg image for the front of the cards, it seems like it would be a lot of repetitive code aside from the change in filename for the front of the card images.
Here's a snippet of the homework assignment, again I just need help getting this part correct, I really appreciate any help with this.
Your job is to supply the custom component named Card. Create the
component by using File → New → MXML Component. In the popup dialog
box
leave the Package blank
Name the component Card
Base Card on spark.components.Image
What goes into the Card component?
For each card, we'll want to be able to show the front face of the
card, or its back face. That means each card should have a place to
store information about what file to show as its front face, and what
file to show as its back face.
To do this, create two variables in the Card component to store the
file names. You might call these variables backImage and frontImage.
Your access modifier is what's bothering me.
If you're creating these definitions in your class file, then the first statement works:
public var backOfCard:Image = new Image();
But if you're in one of the methods, usually the constructor (sometimes called the ctor), or any other method of the application, you could use the 2nd statement:
backofCard.source = 'asset/backImage';
But the combination of both is what I think is confusing. Because the "access modifier" (i.e. public, private, internal, protected) is what you use to define variables and methods within a class. And since you're putting both side-by-side (a definition and an assignment statement), I think you're mixing when to declare them.

What is the complementary event of 'show' for flex displayobjects

Since flex memory management is poor, objects once instantiated dont die very easily (even when they go out of scope), one would need to check on various properties of components. I am using one such thing to know if the screen (which is a display object) is in current view. For this I am turning on a boolean property (currently visible), and I am setting it true on show event of the display object.
What I need to know is, which event (something opposite of show, e.g left?) could be used when the screen is replaced by another display object?
Something like focusIn and focusOut from dotnet.
Or if there is some property which could directly tell me if the display object is currently in view (hasFocus doesnt seem to be giving me expected results).
Thanks.
You can Use PropertyChageEvent check the documentation and base of the newValue and kind property you can do some action :
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/events/PropertyChangeEvent.html
hope this help
Name of the event is: removedFromStage.