06

сен

# Autocad Draw Polyline Vba Programming

Posted:

Nov 15, 2014 - This is Excel VBA Code to get coordinates of Polylines from AutoCAD as. Delete Exit For End If Next i '-- Add Object to AutoCad SelectionSet. Draw A Polyline In AutoCAD Using Excel VBA Posted on April 5, 2013 by Christos Samaras A friend of mine, who is surveying engineer, asked me recently if it is possible to draw a polyline in AutoCAD using coordinates from an Excel file.

If you want to become an expert AutoCAD® script writer, at some point you’re going to need to know a bit about maths, or at least have the capacity to learn. It doesn’t have to calculus, but stuff like Pythagoras theorem and trigonometry are very much your friend in a geometric environment such as AutoCAD®. Cringing yet? Don’t worry – often it’s not as difficult as it seems. I’ve been asked how to replicate the measure command along an arc – there is no real simple answer (that I can think of). 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. So for the purposes of this post I will be showing you how to calculate and draw a circle of points using VBA. Obviously an arc is merely just part of a circle, so isn’t really any different. Although we’re using VBA for convenience, the rationale behind the exercise will work in any programming language. Step One – Get it clear in our minds Logically, to define a circle in 2D space, you need to know the centre for the circle, and the radius. It’s no coincidence then that this is exactly what is required by the CIRCLE command in AutoCAD. To define a point on the circumference of that circle then – if you have defined your circle, all you need is an angle.

From that angle, we can logically derive the point on the circle at that angle. Top spin 4 pc crack games decryption. 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. Now we have to convert that logic into code. Step Two – Understand Sine and Cosine One of the key things that will be at work here will be the use of the trigonometric functions sine and cosine. 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’ve never been a fan of that kind of “learning”.

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. Consider the image below: Assuming a hypotenuse (the angled lines coming from the centre) length of 1, sine is the length of the deflection in the Y axis for a given angle. 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. It’s as simple as that.

Cosine is equally as simple, but rather than the deflection in the Y axis, it will return the deflection in the X axis. So, Cosine 30 = 0.866. This is how we are able to determine the length of sides in a triangle from angles through trigonometry. Lets assume the hypotenuse is actually 4. 