Link to code
I am attempting to move 5, individual pictures (as defined at the beginning of the code) and manipulate each picture in a different way. Each function that is used to manipulate a picture has a pretty obvious name for what is going to happen to that picture
I am using Jes to code this in Jython.
My problem is that even though I clearly specify where on my final canvas that I want these pictures to go to, they for some reason all default to (0, 0). So basically, the only picture that will be displayed is whichever the last one is that is called on. If you were to comment out the last picture, which in the code is the fifth (the "lighten" one), the fourth picture would be the one that got displayed instead so this proves that the pictures are all defaulting to (0, 0). The pictures do not go to their designated spots and that is what I am having trouble with.
***Side note: the functions "greyScale", "colorAvg", "colorSwap", and "lighten" should have nothing to do with the problem. I also don't think my "copy" function should be a problem either but I could be wrong.
I changed my copy function so that the parameters are (picture, destination, targX, targY)
Then in the copy function I made it:
targetX = targX
and then later
targetY = targY
Related
I created a graph that looks alright to me with the following line of code:
df_wide.plot.area(xticks=df_wide.index, legend=False, xlabel= 'Week', ylabel='Percent', title='Percentage of Letters')
However I would like to add the name of selected (or all) dataseries to the right side of the Graph, so that it attaches little lines to the right side and the column name appears next to it, I attach a picture with my current output and how I want it to look (not exactly well edited, but I am sure you get the idea)...
Maybe somebody can helb me :) Thank you!
I'm tearing my hair out trying to work with generatedpoints in draft view. I have a 3D model with points that are named in a particular way, per the picture below:
point names
Then on the CATDrawing, I have generated views that show those points. if I click those points in 2D, they are named in the following manner, "GeneratedPoint (insert 3D point name here)". You can see this naming example below:
2D generated naming
Now, what I'm trying to do in VBA is run a code that will select those generated points in a view, duplicate geometry on them, and name that duplicated geometry to match the 3D point names. My problem is, I can't seem to access the "GeneratedPoint" names that show up when I click the points in 2D. Below is a snippet of my code where I'm trying to access the name of the selected points:
For j = 1 To totalcnt
Set bSel = aDoc.Selection
bSel.Add ActiveView
bSel.Search "Name='*GeneratedPoint *',sel"
Set nm = bSel.Item(j)
desc = nm.Name
desc = nm.Value.Name
Usually when I have a selection, and I make an object from one of those selections, I can access the name through selection.Item(j).Name or selection.Item(j).Value.Name, but in this case neither one works.
at the desc=nm.Name line above, it gives me a name of "CATIASelectedElement16", not the actual name I see in the status bar when I click it in the drawing. And when I use desc=nm.Value.Name it gives me "Front View", which is the name of the view these points are in. I know it's selecting the points correctly, I can see them get selected, and I can see the count on the selection object matches my number of points. What am I missing? For reference, when I run the line Set nm=bSel.Item(i), that object looks like this in the Locals window.
Object in Locals window
As you can see in that picture, the object Type is DrawingView, whereas I would expect it to be a point. Does anyone have any ideas on how to access the name of a generated item in 2D? So far the only way I can interact with it at all is by using selection.Search, which will find them by name, but I have no way of then actually using the specific names of those points it found. Any insight would be appreciated!
I wrote a function that copies a range/table from Excel, pastes it into a PowerPoint Slide and changes size and position. The code works as expected when executed alone, but not so when executed in a series of function calls.
In those cases the size is kept as changed but the shape/table is moved to another position. It seems the scaling is changed later on, but I don't know why. The new table can be seen at its correct position in the slide thumbnail in the left overview, but not so in the slide itself. (edit: This changes after a few second when opening the slide. Which means at some point during the code execution the shape was at the correct position.) I put a debut.print before and after the two parameters left and top to see what happens.
Left (debug.pring after insert): 48 (error!!)
Left (debug.print after change): 48.02496 (as coded/wanted)
Left (after whole macro finished): 384.025 (as later read out by immediate)
The issue seem to be with the scaling of the first two read outs. When I run the function without repositioning. The position it is inserted at is 384... and when changed to 48... it looks as expected. But in my case, what should be 384... is at the moment of insert 48. When changed to 48..., the shape is of course only moved a tiny bit. But then the whole slide seems to be rescoped and suddenly what used to be 48... is then 384..., instead of being 384... in the first place.
How is that possible? How can I counter it?
I don't even know what error to google for, since this seems so random.
I am trying to rotate a shape. Below is the relevant snippet.
Sheets("Sheet1").Shapes.Range(Array("Down Arrow 8")).Select
Selection.ShapeRange.Rotation = 90 + Sheets("Sheet2").Range("H8")
My problem is that the last line randomly works and randomly doesn't! I used to have it as a number (instead of a to string) but this refuses to work! It worked fine, then I made some changes to the macro and then it helpfully returned Error 438 - Object doesn't support this property or method. I fiddled around, debugged, etc (without ever changing the code) and it started working! Then I made some more changes and it stopped working and it seems to have stopped working for good. I literally copied this code from a recorded macro.
What I have tried:
Using CStr() to convert the value to a string
Declaring a variable and using the variable
What I really don't understand is why it would work without me changing the code and them stop working without me changing the code (i.e. the relevant lines)
A few things. First, avoid select. It isn't necessary and will save you a lot of headache and time in the future. Second, you can reference the shape by its name right from the Shapes object, assuming you are only intending to rotate one shape with the code. Finally, are you certain the value in Sheets("Sheet2").Range("H8") is numeric? If not, this could cause an error. The code below handles the first two issues. Beyond that, we'll need to see more code to determine the error.
Sheets("Sheet1").Shapes("Down Arrow 8").Rotation = 90 + Sheets("Sheet2").Range("H8")
I have used line() function in matlab to draw line over an image. The line is drawn successfully but the problem is it is not saving on the image or in other words I can't save the line drawn image. I need this lined image for later stages. I can see the lined image. But it is not shown when again that particular image is loaded.
Your question is too specific, but to give you an idea. Images in Matlab are saved as a matrix so you have a column and row of values.
You can alter or access a column or a row of an image easily using the : operator. For instance, to get the first row of data you can do img(1,:), that is to mean all elements in the first row.
I hope with this hint you can solve your problem easily.
You are probably looking for
hold on;
For example:
figure();
plot(1:10,1:10);
hold on;
plot(1:10,2:11,'r')