Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Vector Drawing

Status
Not open for further replies.

Rednyx

Civil/Environmental
Feb 22, 2001
42
Now here is the problem
The inputs are the length of beams
as the lengths are entered i want to show a solid line corresponding the beam.
the second input is the location of load on the beam.
Now i want a vert line representing load to be dispalyed over the previos solid line. let suppose the first beam(hor.) was of 10 ft now the loads are at 3 ft from right.
i just want to kno which topic i should scroll for this and if i can get hints onthis it would be great.
thanx
 
Replies continue below

Recommended for you

Is this a VB problem? Do you want to automate the drawing of lines in a CAD package? If so, which one? Need more info! DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
 
To draw a line, use the AddLine method:
Code:
Set lineObj = ThisDrawing.ModelSpace.AddLine(pt1, pt2)
[code]

How much do you have programmed so far? Can you connect to AutoCAD? Open an existing drawing or start a new drawing? Do you have a front end to get the user's inputs?
 DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
 
i Havent yet programmed far enough to open a new drawing in the running VB prog.
Is it true that every time i call a new autocad drawing to start the whole auotoCAD software is launched with it, as it can slow the procedure a lot.
I have an EXE file of such a programme made on VB with me is there a way to DECODE it?
 
What versions of VB and AutoCAD are you using? DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
 
I am not sure about reverse engineering an exe file. I will try to work up a sample of how to interface with AutoCAD, start a new drawing, draw a part and save the file. Time is short right now, but it is on the list! DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
 
i know how to open the saved autocad file on VB6 .. i was wondering how to use it through running of vb programme?
either tell me or guide me to the source plz
 
Start a new VB Project. To Form1, add two text boxed and name them (txtLength and txtHeight). Add two buttons and name them (cmdOK and cmdCancel). Add this code to the form:
Code:
Option Explicit

Private Sub cmdCancel_Click()
    Unload Me
    End
End Sub

Private Sub cmdOK_Click()
    Dim rLen As Double, rHgt As Double
    Dim CadApp As AcadApplication
    Dim CadDwg As AcadDocument
    Dim lineObj As AcadLine
    Dim textObj As AcadText
    Dim pt1(0 To 2) As Double, pt2(0 To 2) As Double, pt3(0 To 2) As Double
    Dim pt4(0 To 2) As Double, pt5(0 To 2) As Double
    Dim x As Integer, y As Integer, z As Integer
    x = 0
    y = 1
    z = 2

    'Get the textbox values
    If IsNumeric(txtLength.Text) = True Then
        rLen = CDbl(txtLength.Text)
    Else
        MsgBox "Invalid Length"
        Exit Sub
    End If
    If IsNumeric(txtHeight.Text) = True Then
        rHgt = CDbl(txtHeight.Text)
    Else
        MsgBox "Invalid Height"
        Exit Sub
    End If
    '<><><><><><><><><><><><><><><><><><><><><>
    '  Connect to AutoCAD
    '<><><><><><><><><><><><><><><><><><><><><>
    On Error Resume Next
TryAgain:
    Set CadApp = GetObject(, &quot;AutoCAD.Application&quot;)
    If Err.Number <> 0 Then     'Not Running
        Set CadApp = CreateObject(&quot;AutoCAD.Application&quot;)
        Err.Clear
        'AutoCAD may open a new drawing upon opening - close it
        CadApp.ActiveDocument.Close False
        If Err.Number <> 0 Then
            Err.Clear   'No Drawings are Open
        End If
    End If
    On Error GoTo 0
    'Add a new drawing
    CadApp.Documents.Add
    Set CadDwg = CadApp.ActiveDocument
    
    'Define the points - start at 0,0
    pt1(x) = 0#: pt1(y) = 0#: pt1(z) = 0#
    
    pt2(x) = pt1(x) + rLen
    pt2(y) = pt1(y)
    pt2(z) = 0#
    
    pt3(x) = pt2(x)
    pt3(y) = pt2(y) + rHgt
    pt3(z) = 0#
    
    pt4(x) = pt1(x)
    pt4(y) = pt3(y)
    pt4(z) = 0#
    
    'Draw the lines
    Set lineObj = CadDwg.ModelSpace.AddLine(pt1, pt2)
    Set lineObj = CadDwg.ModelSpace.AddLine(pt2, pt3)
    Set lineObj = CadDwg.ModelSpace.AddLine(pt3, pt4)
    Set lineObj = CadDwg.ModelSpace.AddLine(pt4, pt1)
    
    'Add some text
    pt5(x) = (pt1(x) + pt2(x)) / 2
    pt5(y) = (pt1(y) + pt4(y)) / 2
    pt5(z) = 0#
    
    Set textObj = CadDwg.ModelSpace.AddText(&quot;HERE YOU GO!&quot;, pt5, 0.125)

    CadApp.ZoomExtents
    
    Set lineObj = Nothing
    Set CadDwg = Nothing
    Set CadApp = Nothing
    
    Unload Me
    End
End Sub

This sample will create a new drawing. Instead of CadApp.Documents.Add, use the CadApp.Documents.Open command to open an existing drawing. Then, the
Set CadDwg = CadApp.ActiveDocument
command will attach to the active drawing. From there, you can do whatever you need. DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor