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!

hey.. i have a question regarding t

Status
Not open for further replies.

keeyean

Civil/Environmental
Sep 11, 2001
14
hey.. i have a question regarding the code below..
i can draw the line in ACAD_ISO02W100...??
can someone correct for me??

Set acadApp = GetObject(, "autoCAD.application")
Set acadDoc = acadApp.activedocument
Set modelspace = acadDoc.modelspace

Dim PLine2Obj As Object
Dim Points2(0 To 14) As Double

EWNS = -315
Points2(0) = -513.8151: Points2(1) = 10 + EWNS: Points2(2) = 0
Points2(3) = -493.8151: Points2(4) = 10 + EWNS: Points2(5) = 0
Points2(6) = -493.8151: Points2(7) = 100 + EWNS: Points2(8) = 0
Points2(9) = -513.8151: Points2(10) = 100 + EWNS: Points2(11) = 0
Points2(12) = -513.8151: Points2(13) = 10 + EWNS: Points2(14) = 0
Set PLine2Obj = modelspace.AddPolyline(Points2)
modelspace.Linetypes.Load "ACAD_ISO02W100", "acad.lin"
PLine2Obj.Linetype = "ACAD_ISO02W100"
 
Replies continue below

Recommended for you

First, you should not have an object named modelspace. This object is already reserved by the AutoCAD API.

You should also declare the plineObj as a polyline:
Dim PLine2Obj As AcadPolyline

Set cadApp = GetObject(, "AutoCAD.Application")
Set cadDoc = cadApp.ActiveDocument

Dim PLine2Obj As AcadPolyline
Dim Points2(0 To 14) As Double

EWNS = -315
Points2(0)=-513.8151:points2(1)=10+EWNS:points2(2)=0
Points2(3)=-493.8151:points2(4)=10+EWNS:points2(5)=0
Points2(6)=-493.8151:points2(7)=100+EWNS:points2(8)=0
Points2(9)=-513.8151:points2(10)=100+EWNS:points2(11)=0
Points2(12)=-513.8151:points2(13)=10+EWNS:points2(14)=0

Set PLine2Obj = cadDwg.ModelSpace.AddPolyline(Points2)

cadDwg.ModelSpace.Linetypes.Load "ACAD_ISO02W100", "acad.lin"

PLine2Obj.Linetype = "ACAD_ISO02W100"
[/code]
Hope this helps! DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
 
But this is only work in AutoCAD API...
i tried to use the same code in visual basic.. but it doesn't work.... it can't load the linetype...:(

besides,, what about the ZoomALL command?? coz i doesn't define in visual basic..
 
First, make sure that you add the AutoCAD Object Library to your project references. Second, the Linetypes object is not a part of the ModelSpace, it is derived from the AcadDocument object.

I started a new VB application that contained a single form. I put a command button on that form and put this code behind it.
Code:
Option Explicit

Dim cadApp As AcadApplication
Dim cadDoc As AcadDocument

Private Sub Command1_Click()
    Dim EWNS As Integer
    Set cadApp = GetObject(, "AutoCAD.Application")
    Set cadDoc = cadApp.ActiveDocument
        
        
    Dim PLine2Obj As AcadPolyline
    Dim Points2(0 To 14) As Double
        
    EWNS = -315
    Points2(0)=-513.8151:Points2(1)=10+EWNS:Points2(2)=0
    Points2(3)=-493.8151:Points2(4)=10+EWNS:Points2(5)=0
    Points2(6)=-493.8151:Points2(7)=100+EWNS:Points2(8)=0
    Points2(9)=-513.8151:Points2(10)=100+EWNS:Points2(11)=0
    Points2(12)=-513.8151:Points2(13)=10+EWNS:Points2(14)=0
    
    Set PLine2Obj = cadDoc.ModelSpace.AddPolyline(Points2)
    
    cadDoc.Linetypes.Load "ACAD_ISO02W100", "acad.lin"
    PLine2Obj.Linetype = "ACAD_ISO02W100"
    
    cadApp.ZoomAll
    
    Unload Me
    End
End Sub
DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
 
it doesn't work too...:(
cadApp As AcadApplication.... coz undefined on the statement....??

besides, how to i add the AutoCAD Object Library to my project references??

sorry to ask so many questions to you...:(
 
Are you using VB? If so, go to Project>References. Find the AutoCAD Object library in the list and check the box. This links your program to the AutoCAD API.

If you are using VBA, in, let's say Excel, go to Tools > References and do the same thing. DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
 
i got it..
thanz you so much..:)!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor