Message 1 of 7
help moving vba to vb
Not applicable
04-07-2009
06:10 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have about a 100 VBA routines that I need to convert to VB but need help
getting started. Until I can truly convert my routines to dot net one by
one (still learning) I'd like to be able to still use them in vb if
possible. It appears but I could be wrong if I can get access to the
thisdrawing most of my routines could still run. (hoping) virtually all my
routines simply draw polylines of varying shapes and layers.
Any help you can provide on what references need to be assigned to get
thisdrawing function or am I out of luck until I learn dot net. Below is
basically what I'm trying convert. pick a point, set a direction, turn some
angles from direction, draw ployline.
Have a great day,
John Coon
Imports System
Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD.Interop.Common
Dim dblRot As Double
Dim point1 As Variant
Dim point2 As Variant
Dim point100 As Variant
Dim point101 As Variant
Dim point102 As Variant
Dim pi As Double
Dim ThisDrawing As AcadDocument
ThisDrawing = DocumentManager.MdiActiveDocument.AcadDocument 'this is not
working
Dim layerObj As AcadLayer
layerObj = ThisDrawing.Layers.Add("C-STRP")
ThisDrawing.ActiveLayer = layerObj
objWCS = ThisDrawing.UserCoordinateSystems.Add(dblOrigin, dblXVector,
dblYVector, "WCS")
ThisDrawing.ActiveUCS = objWCS
'point1 = ThisDrawing.Utility.GetPoint(, "Pick Centerline Start Location,")
'point2 = ThisDrawing.Utility.GetPoint(point1, "Select Direction Mid point")
point1(0) = 0.0
point1(1) = 0.0
point2(0) = 500.0
point2(1) = 0.0
dblRot = ThisDrawing.Utility.AngleFromXAxis(point1, point2)
Dim rw1, rw2, rwdist As Double
rw1 = point1(0) - point2(0)
rw2 = point1(1) - point2(1)
rwdist = Math.Sqrt(rw1 ^ 2 + rw2 ^ 2)
'MsgBox("dist is = " & rwdist)
point100 = ThisDrawing.Utility.PolarPoint(point1, (pi + dblrot), -50)
point101 = ThisDrawing.Utility.PolarPoint(point100, (pi + dblrot), -50)
point102 = ThisDrawing.Utility.PolarPoint(point100, (pi + dblrot),50)
Dim DRWPOLY As AcadLWPolyline
Dim points(3) As Double
points(0) = point101(0): points(1) = point101(1)
points(2) = point102(0): points(3) = point102(1)
Set DRWPOLY = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)
getting started. Until I can truly convert my routines to dot net one by
one (still learning) I'd like to be able to still use them in vb if
possible. It appears but I could be wrong if I can get access to the
thisdrawing most of my routines could still run. (hoping) virtually all my
routines simply draw polylines of varying shapes and layers.
Any help you can provide on what references need to be assigned to get
thisdrawing function or am I out of luck until I learn dot net. Below is
basically what I'm trying convert. pick a point, set a direction, turn some
angles from direction, draw ployline.
Have a great day,
John Coon
Imports System
Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD.Interop.Common
Dim dblRot As Double
Dim point1 As Variant
Dim point2 As Variant
Dim point100 As Variant
Dim point101 As Variant
Dim point102 As Variant
Dim pi As Double
Dim ThisDrawing As AcadDocument
ThisDrawing = DocumentManager.MdiActiveDocument.AcadDocument 'this is not
working
Dim layerObj As AcadLayer
layerObj = ThisDrawing.Layers.Add("C-STRP")
ThisDrawing.ActiveLayer = layerObj
objWCS = ThisDrawing.UserCoordinateSystems.Add(dblOrigin, dblXVector,
dblYVector, "WCS")
ThisDrawing.ActiveUCS = objWCS
'point1 = ThisDrawing.Utility.GetPoint(, "Pick Centerline Start Location,")
'point2 = ThisDrawing.Utility.GetPoint(point1, "Select Direction Mid point")
point1(0) = 0.0
point1(1) = 0.0
point2(0) = 500.0
point2(1) = 0.0
dblRot = ThisDrawing.Utility.AngleFromXAxis(point1, point2)
Dim rw1, rw2, rwdist As Double
rw1 = point1(0) - point2(0)
rw2 = point1(1) - point2(1)
rwdist = Math.Sqrt(rw1 ^ 2 + rw2 ^ 2)
'MsgBox("dist is = " & rwdist)
point100 = ThisDrawing.Utility.PolarPoint(point1, (pi + dblrot), -50)
point101 = ThisDrawing.Utility.PolarPoint(point100, (pi + dblrot), -50)
point102 = ThisDrawing.Utility.PolarPoint(point100, (pi + dblrot),50)
Dim DRWPOLY As AcadLWPolyline
Dim points(3) As Double
points(0) = point101(0): points(1) = point101(1)
points(2) = point102(0): points(3) = point102(1)
Set DRWPOLY = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)