I am trying to measure distance between a line and a point using below code.
ptref = Partdocument.Part.CreateReferenceFromObject(pt1) 'creating reference from point
refline = Partdocument.Part.CreateReferenceFromObject(line1) 'creating reference from line
Get measure
TheMeasurable = TheSPAWorkbench.GetMeasurable(refline)
dist1 = TheMeasurable.GetMinimumDistance(ptref)
since line and point are at different plane, I am not getting the required output.
I want to to measure using "Any geometry, infinite option".
Please suggest how I can incorporate that.
That is not supported using the SPAWorkbench/Measurable.
As a workaround, it is not difficult to get the end points of the line and perform the calculation using vector algebra.
Related
Along a known line, I am trying to extract a list of point at set distances from the end of the line. e.g. 30cm and 65cm from the end of the line.
I have been exploring ezdxf but haven't found a simple function to achieve this.
Diagram: Known points in blue, required positions marked in red
For CATIA V5, the following lines of code prompt the user to select a feature, filtered by type.
Dim InputObjectType(0) As Variant
InputObjectType(0) = "Point"
selection1.SelectElement2(InputObjectType, "Select a point", true)
etc...
I want to filter on Geometrical Sets. "Geometrical Set", "GeometricalSet", and "GeoSet" do not work. Is there a list or table of object type names? The v5automation.chm file does not offer any clues.
Not sure if you're checking SO for answers or not - doesn't look like many others have been able to answer your questions to date
If this works for you please mark it as an answer and gain points for yourself as well as myself - and helping future users
I believe you can find a Geometrical set by searching for "HybridBody"
Note: Both Geometric set and Repetition(Points and Planes) are HybridBody
Change your lines of code to:
InputObjectType(0) = "HybridBody"
selection1.SelectElement2(InputObjectType, "Select a Geo Set", true)
Found a list of types - not sure if it's full or not
Other
Volume
Surface
Cylinder
Sphere
Cone
Plane
Curve
Circle
Line
Point
Axis System
There is a generic elements list:
And you can use other filters using the same name used in VBA and not for user interface.
HybridBody = API
GeometricalSet = UI
I'm currently working on converting a VBA AutoCAD-application over to VB.NET, and the current command I'm working on is creating a simple leader with code like this:
Set leaderObj = ThisDrawing.ModelSpace.AddLeader(points, blockRefObj, leaderType)
leaderObj.ArrowheadType = acArrowDotSmall
leaderObj.ArrowheadSize = 2.5 * varDimscale
leaderObj.DimensionLineColor = acWhite
I've been able to create the Leader-line in .NET using
Dim l = New Leader()
For Each point In jig.LeaderPoints
l.AppendVertex(point)
Next
l.Dimldrblk = arrId
The arrId I got from using the function found here, but I've been unable to figure out how to set the color of the leader to white (it shows up as red by default), and also how to set the size of the arrowhead. If anyone could help me out with this I would be most grateful.
Ok, after a lot of trial and error, I figured out that the solution was rather simple. I didn't have to override any dimension styles (which I honestly don't even know what is, I had a short beginners course in AutoCAD before getting handed this project), I simply had to set an obscure property on the Leader-object. For future references, and for anyone else trying to do the same, here's the properties I ended up using:
leader.Dimclrd
The color of the leader-line. Stands for something like "dimension line color".
leader.Dimasz
The scale of the leader-head.
As type BlockReference, it should have a color property and the property should be an Autodesk.Autocad.Colors.Color or an Integer. Also the reason you are getting the object for read is, in your transaction you are opening the database with
OpenMode.ForRead
And that is correct. But to edit the object in the database, you must retrieve the object like below
var obj = Thetransaction.GetObject(theobjectid,OpenMode.ForWrite) as BlockReferance;
This is done inside of the
using(var trans = TransactionManager.StartTransaction()){}
I'm doing this on a cell, so check the camel case and syntax because I write in c#, but it should be pretty close.
You may want to see if there is a scale property, as to change the size.
Hopefully this will move you in the right direction.
Let me know if you have any problems. :)
I have a datafile with multiple columns, the first two indicating the position and the others indicating other properties (such as number of items sent from this point). eg:
1 1 1 57.11
2 1 2 62.40
3 4 1 31.92
What I want to do is plot the points at the positions, but use values from the other columns to vary point type and size (for example). However I can't seem to find a way to reference columns in the plot. I know of the use of "variable", but I cant find a way to use multiple variables.
What I want is something like the following:
plot "mydata" using 1:2 notitle with points pt ($3) ps ($4/10)
so that pt and ps use the value for each point taken from the third and fourth columns respectively.
Is this even possible in gnuplot? Is there some sort of work-around?
You should be able to use the keyword variable to do something like this:
plot 'datafile' using 1:2:3:4 w points ps variable lc variable
Or possibly mapping the value to a palette:
plot 'datafile' using 1:2:3:4 w points ps variable lc palette
The keyword variable and/or palette causes gnuplot to read the properties from the file and they both require an extra column to be read via using. Of course all the usual stuff with using applies -- You can apply transforms to the data, etc:
plot 'datafile' using 1:2:3:($4+32.) w points ps variable lc palette
I don't remember off the top of my head whether the 3rd column will be the pointsize or the color here, and I don't have time right now to play around with it to figure it out. You can do the experimenting and post a comment, or I'll come back to this when I have time and add an update.
Some of the other properties (e.g. pointtype) can't be changed quite to easily using variable. The easiest way to do this is to use filters with the gnuplot ternary operator.
First, write a function that returns a pointtype based on the data from 1 column of the datafile:
my_point_type(x) = x
Here I use a simple identity function, but it could be anything. Now, you can loop over the pointtypes you want (here 1-10) making a plot for each:
plot [for PT=1:10] 'datafile' u 1:((my_point_type($3) == PT) ? $2:NaN) with points pt PT
This assumes that the column with pointtype information is the 3rd column and that the second column holds the position information. This can also be combine with the stuff that I demonstrated above.
I didn't find any method on java api to do this... there is one like : line.contains(point).. but it says that line2d doesn't have any area so it will return always false..
Any idea ?
Compare point by point and see if the cursor matches it.
You can do the search using the for each loop described here.
You should compute the distance from the point to the line, and if it is sufficiently small, then consider the point being on the line.
Google "distance point to line" or "distance point to segment".