×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

hey.. i have a question regarding t

hey.. i have a question regarding t

hey.. i have a question regarding t

(OP)
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"

RE: hey.. i have a question regarding t

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"
ÿ
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.

RE: hey.. i have a question regarding t

(OP)
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..

RE: hey.. i have a question regarding t

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.

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.

RE: hey.. i have a question regarding t

(OP)
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...:(

RE: hey.. i have a question regarding t

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.

RE: hey.. i have a question regarding t

(OP)
i got it..
thanz you so much..:)!!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Resources

Low-Volume Rapid Injection Molding With 3D Printed Molds
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Design for Additive Manufacturing (DfAM)
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a part’s function at the center of their design considerations. Download Now
Taking Control of Engineering Documents
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close