3 methods draw entities

Discussion in 'AutoCAD' started by Adesu, Jun 14, 2004.

  1. Adesu

    Adesu Guest

    Lesson 3 -- Drawing the Path Boundary
    Drawing AutoCAD Entities

    Most AutoLISP programs draw entities using one of several methods:

    ActiveX functions
    The entmake function
    The command function

    Can anybody give me sample,how to draw entities by "ActiveX" function,second
    and third function I've known it,thanks for your reply.
    Best regards
    Ade Suharna
     
    Adesu, Jun 14, 2004
    #1
  2. Adesu

    Jeff Mishler Guest

    This will place a new line in the current drawing's modelspace on the
    current layer:

    (setq pt1 (getpoint "\nSelect line start point: ")
    pt2 (getpoint pt1 "\nSelect line end point: "))
    (setq newline (vlax-invoke (vla-get-modelspace
    (vla-get-activedocument
    (vlax-get-acad-object)))
    "addLine"
    pt1
    pt2
    ))

    Good luck!
    Jeff
     
    Jeff Mishler, Jun 14, 2004
    #2
  3. Adesu

    Adesu Guest

    Hi Jeff,What wrong ??
    (setq pt1 (getpoint "\nSelect line start point: ")
    pt2 (getpoint pt1 "\nSelect line end point: "))
    (setq newline (vlax-invoke (vla-get-modelspace
    (vla-get-activedocument
    (vlax-get-acad-object)))
    "addLine"
    pt1
    pt2
    ))
    (18.7673 12.5217 0.0)
    ; error: no function definition: VLAX-GET-ACAD-OBJECT ;>>>> ????
     
    Adesu, Jun 14, 2004
    #3
  4. Adesu

    Adesu Guest

    Help to fill in,thanks

    (setq pt1 (getpoint "\nSelect line start point: ")
    pt2 (getpoint pt1 "\nSelect line end point: "))
    (setq newline
    (vlax-invoke ; >>>>>> call the specified ActiveX method
    (vla-get-modelspace ; >>>>>> ?????
    (vla-get-activedocument ; >>>>>> ?????
    (vlax-get-acad-object ; >>>>>> Retrieves the top level AutoCAD
    ; >>>>>> application object for the
    current
    ; >>>>>> AutoCAD session
    )))
    "addLine" : >>>>>> ?????
    pt1
    pt2
    ))
     
    Adesu, Jun 14, 2004
    #4
  5. Adesu

    Jeff Mishler Guest

    First, I should have mentioned that (vl-load-com) needs to be run once in a
    drawing before the activex commands can be run. That should eliminate the
    error you got.
    See below

    To break it down further, you could do this:
    (setq acad (vlax-get-acad-object))
    (setq doc (vla-get-activedocument acad));;This could also be written as
    (vlax-get-property acad 'activedocument)
    (setq mspace (vla-get-modelspace doc));; OR (vlax-get-property doc
    'modelspace)
    (setq newline (vlax-invoke mspace "addline" pt1 pt2));; this could also be
    written using (vla-addline), but then the pt1 & pt2 lists would need to be
    converted to vlax-variants which is a whole 'nother "can of worms".

    Hope that helps,
    Jeff
     
    Jeff Mishler, Jun 14, 2004
    #5
  6. Adesu

    Adesu Guest

    I've tried in ac 2004 it's OK
     
    Adesu, Jun 14, 2004
    #6
  7. Adesu

    Adesu Guest

    Very very very thanks a lot Jeff,now my knowledge added again
     
    Adesu, Jun 14, 2004
    #7
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.