I have automated intersecting Pad to Line which results in 2 points. I am trying to get intersecting points Coordinates. However, I can only get 1 point's coordinates in Msg Box. Can anybody suggest a way of how can I get?
thanks
At this moment I have only 1 intersection point and my code is working. but if I have 2 points of intersection I get an error "The method GetPoint failed". what can I do to solve it?
Related
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 want, when a point is selected, the co ordinate values of the point to display in a userform:
Values of x, y & z should be displayed in the textboxes.
Some points are in "ONCURVE" or "ONSURFACE" type. Those points won't show x, y & z values.
Image for reference
First point is co-ordinate defined, second point is ONCurve defined and the third is ONSURFACE defined.
How do I extract x y z co-ordinate values for those points?
I also need to change the point location by changing the values from the textbox.
As GisMofx said, you should use the base Point class and you can use the methods GetCoordinates
Take a look in the API documentation - you should be able to find some examples and if not try to come up with something
CATIA API Point Description
After trying a few things inside small basic to make a line follow the mouse but not move the entire line, I recently came across a problem. Originally I was trying to constantly have a line update so as it stays connected from one point to the mouse position by clearing the graphics window and redrawing a line from the bottom right to the mouse. This could not work and was to resource intensive. However, now I have come across Shape.addline and shape.move. But I'm not too sure as to how they work, from my understanding, a shape can have it's own name by doing:
[Shapename] = Shapes.addline(positions)
and then that shape can be moved using:
Shapes.move(Shapename,Coordinates)
In my case it's:
L1 = Shapes.AddLine(0,GraphicsWindow.Height,GraphicsWindow.MouseX,GraphicsWindow.MouseY)
(Drawing a line from the bottom left corner to the mouses position)
and
Shapes.Move(L1,GraphicsWindow.MouseX,GraphicsWindow.MouseY)
The only problem is that Shapes.Move only supports 3 arguments being:
shapeName
X
Y
But, when drawing the line (Shapes.AddLine), I use 4 arguments:
X1
Y1
X2
Y2
This means I can only control those two positions. So, how would you control the other two? If we can only modify X1 and Y1, is there any way of still using at least something similar to the shape.move method but be able to control the other X2 and Y2 positions? Primarily, I would like to actually Only change the X2 and Y2 positions, as I'm trying to make a line originate from one point and stay there, then alter the opposing point so that it follows the mouse, and not move the entire shape. If none of this is possible, is there any known way of moving / changing only the X2 and Y2 coordinates of a line without having to clear the entire screen?
Ah yes. These are the shortcomings of small basic. Shapes.move will not let you define a starting and ending point of a line. What you will need to do is move the center of the line in between the first point and the cursor, and the rotate it correctly. Like so:
Mouseline = Shapes.AddLine(0,0,100,0)
Shapes.Move(Mouseline,200,200)
GraphicsWindow.MouseMove = OnMouseMove
Sub OnMouseMove
XDif = (GraphicsWindow.MouseX-250)
YDif = (GraphicsWindow.MouseY-200)
If XDif <> 0 Then
MouseAngle = Math.ArcTan(YDif/XDif)
EndIf
If XDif < 0 Then
MouseAngle = MouseAngle + 3.14 '180 degrees in radians
EndIf
Shapes.Rotate(Mouseline,Math.GetDegrees(MouseAngle))
Shapes.Move(Mouseline,(Math.Cos(MouseAngle)*50)+200,(Math.Sin(MouseAngle)*50)+200)
EndSub
Another way of doing this is with the LitDev extension (http://litdev.co.uk/). It has a MoveLine(x1,y1,x2,y2) function in it.
im guessing u would alter the end of the program where it says math.cos(mouseangle) change the 200 to 0 and change the other 200 to the bottom. so if what im trying to figure out, ur trying to get the line to only project in the 1st quadrant in a cortesian plane yes?
I'm not sure this is possible but thought this was the best place to ask.
Is it posible to get the position of a series value on a graph in excel?
For example, if I have a line graph in excel that has time along the x axis, is it possible to (using VBA) get the position of a specific point on that axis.
What I am trying to do is have a vertical line that is can be positioned based on a date entered by the user.
like this
Where the green line could be positioned by entering in a date (rather than just being manually moved) (or also it could be set to automatically move to the current date etc).
I was then thinking that if the position is on the graph is queryable, then I can just access the line object and move it to any position I wanted through VBA.
Any Ideas? or is this just not possible?
The "cleanest" way to do this is to add the line to the chart as a new series. In that way, Excel handles all of the positioning and your work is simplified. To get a vertical line on a chart, there are a number of options. I prefer this route:
Create a small 2x2 area with two dates and two values
Add in the date or x-axis value you want the line at (E3 in image). You can use =TODAY() here or some manually entered value.
Set the second x-axis value equal to the first
Use MAX and MIN on the data to get the values for each date. You can also use 0 and 1 and a secondary axis, but I think MAX/MIN is easier.
Add the data to the chart and format as a marker with straight line.
Formulas
E3: =TODAY()
E4: =E3
F3: =MIN(C3:C27)
F4: =MAX(C3:C27)
Result and chart data series for vertical line
Today we are drawing polygons on a MKMapView. We use the following pseudocode to draw polygons.
CGContextMoveToPoint
CGContextAddLineToPoint
CGContextAddLineToPoint
CGContextAddLineToPoint
CGContextClosePath
CGContextFillPath
The result could potentially look like this:
We get the data one row at a time, the colors are given to the cell based on the data we receive. Is there a way or polygon reduction algorithms that would group all the same colored polygons together (assuming they intersect) to give me one big polygon? So in this example all the reds would one big polygon.
CoreGraphics can handle concave polygons natively, so the main part of the problem is a flood fill to work out the boundaries of the filled area.
Thinking extemporaneously, a naive algorithm could be to associate edge flags with each cell. An edge flag is set if that edge is part of the exterior of the polygon. Flags are shared by the two cells that meet at that edge.
Pick any cell and set all four edge flags. Reset the edge flags on all other cells. Then write a recursive method that, for each cell:
tests in turn whether each edge flag is set;
if a flag is set, checks whether the cell that shares that edge is of the same colour;
if it is, inverts the edge flags of that cell and recurses to it.
The inversion is the same as saying "connect to any cells you're known to be next to, set any edges that are next to cells we haven't looked at yet to be part of the boundary".
The recursion could get hundreds of items deep, so it might be worth keeping a list of cells to consider and adding to that list rather than recursing, just as a matter of implementation. It shouldn't matter what order you visit the cells in, so the outcome should be the same.
Once you've run out of cells to visit, you can reconstruct the entire boundary by walking around it from any flagged edge. The only slight complexity will be when you get to a diagonal meeting of cells, like where the yellow and green cells touch between your fourth and fifth columns. You need to apply the logic that you move from the current edge to the next one with which it shares both a vertex and a cell of the correct colour.
This is a job for the rectangle drawing functions, not the path drawing functions. See CGContextFillRect(), CGContextStrokeRect() and CGContextFillRects(). They will be much faster.