Autocad Vba Polyline Arc3/24/2021
If youre more of a VBA user, youll be very pleased to hear that as were using COM, you can pretty much re-use all the VBA code you ever learned.It doesnt have to calculus, but stuff like Pythagoras theorem and trigonometry are very much your friend in a geometric environment such as AutoCAD.Cringing yet Dont worry often its not as difficult as it seems.The way I would do it is through actually calculating the points in 2D space.
This may sound tricky, but languages such as VB really are conducive to this kind of work, and you may be surprised how simple this actually is. Obviously an arc is merely just part of a circle, so isnt really any different. Although were using VBA for convenience, the rationale behind the exercise will work in any programming language. Its no coincidence then that this is exactly what is required by the CIRCLE command in AutoCAD. From that angle, we can logically derive the point on the circle at that angle. So in our minds at least, we know how to define a point on the circumference of a circle using a centre for the circle, a radius, and an angle. I think it is worth delving into what these actually mean, as understanding this can be very helpful for this kind of work. In fact, when I was at school I was taught parrot-fashion how to use SOH-CAH-TOA to work out which trig function to use for which situation. I like to understand the underlying principles so that I can apply them to any situation, but sadly I was never taught in that way. My own curiosity led me to figuring out the diagram below for myself, and it really enhanced my ability to understand trigonometry, and what sine and cosine actually are. So in the example above, a line drawn at 30 a length of 1, will produce a deflection in the Y axis of 0.5. Sine 30 0.5. Its as simple as that. The ratio between the sides is still the same, so the calculation to work out the vertical edge of the triangle (the deflection in the Y axis) is as simple as 4 Sin 30. ![]() Simples. Below is a function that accepts the various inputs we have identified and will draw a point in modelspace. Sub drawPointOnCirc(xPos As Double, yPos As Double, radius As Double, angle As Double). Convert degrees to radians, as required by VBA trig functions. Add the circle centre to the offset values, to get the absolute. We are able to draw a point in modelspace that represents a location on the circumference of a circle. The circle centre is defined at 10,10 with a radius of 3, which is what the arc should show. Autocad Vba Polyline Arc Dll For ExampleThough generally it is better to have tools well integrated into AutoCAD via the use of a NETLOADed dll for example, sometimes an exe can be an elegant solution. If it is not running, launch AutoCAD, and create a reference to it.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |