New in VisualLisp

Discussion in 'AutoCAD' started by Jürg Menzi, Sep 10, 2004.

  1. Jürg Menzi

    Jürg Menzi Guest

    Hi Moshe

    Check this sample:
    Code:
    ;
    ; == Function MeOffset
    ; Error watched Offset method.
    ; Arguments [Type]:
    ;   Obj = Object to offset [VLA-OBJECT]
    ;   Dst = Offset distance [REAL]
    ; Return [Type]:
    ;   > Offset object list [LIST]
    ;   > False if offset fails
    ; Notes:
    ;   None
    ;
    (defun MeOffset (Obj Dst / TmpLst)
    (if (not
    (vl-catch-all-error-p
    (setq TmpLst (vl-catch-all-apply 'vlax-invoke (list Obj 'Offset Dst)))
    )
    )
    TmpLst
    )
    )
    
    Cheers
     
    Jürg Menzi, Sep 10, 2004
    #1
  2. Jürg Menzi

    moshe Guest

    Hi Guys

    I'm new in VisualLisp (vla, vlax stuff) I do well know AutoLISP.

    I have this problems:-

    1. I have draw a object (Line, 2dpolyline, lwpolyline) and execute the
    (vla-offset) function on it. the return value is a variant object.
    How do i convert this variant object to be a valid argument in
    (vla-InterSectWith) function?

    2. (vla-InterSectWith) function also return a variant object. How do i
    convert it to AutoLISP point?

    3. Can i create a virtual object? that is: define the object with all it's
    properties but do not add it to database.
    I need this for the first question. i want to offset an object (stay in
    memory) then check if that object InterSectWith other
    resident objects

    Thanks in Advance

    Moshe
     
    moshe, Sep 10, 2004
    #2
  3. Jürg Menzi

    Jürg Menzi Guest

    Hi Moshe

    Works for me in 2k2, 2k4 and 2k5:
    _$
    _$ (MeOffset (vlax-ename->vla-object (car (entsel))) 5)
    (#<VLA-OBJECT IAcadLine 06b50f14>)
    _$

    Cheers
     
    Jürg Menzi, Sep 10, 2004
    #3
  4. Jürg Menzi

    moshe Guest

    Hi Jurg

    Thank you for your fast reply but I have used your code and this is what i
    get:

    '; error: ActiveX Server returned an error: Parameter not optional'

    ???

    please, do try again

    moshe
     
    moshe, Sep 10, 2004
    #4
  5. Jürg Menzi

    moshe Guest

    Ok Gurg

    You were right (I pass an invalid VLA-OBJECT) now it's working
    but the object I get is an invalid argument to the (vla-InterSectWith)
    function which puts me back
    at the start the problem

    here is what i do:-

    (setq obj1 (vlax-ename->vla-object (car (entsel))))
    (setq obj2 (MeOffset obj1 5))
    (vla-intersectwith obj1 obj2 acExtendNone)
    ; error: lisp value has no coercion to VARIANT with this type:
    (#<VLA-OBJECT IAcadLine 00efe4b4>)

    and also, do you know how to create a virtual object?
    and also, in AcDb2dPolyline object, how can i check if it contains vertices
    [like in AutoLisp (= (cdr (assoc '66 obj) 1)]?

    thanx a lot for your effort.

    moshe
     
    moshe, Sep 10, 2004
    #5
  6. Jürg Menzi

    Jürg Menzi Guest

    Hi Moshe
    MeOffset returns a list:
    ....
    ; Return [Type]:
    ; > Offset object list

    • ; > False if offset fails
      ....
      Extract the object like:
      (setq obj2 (car (MeOffset obj1 5)))

      BTW, offset lines does not intersect...
      What dou you mean with 'viritual object'? Temporary object?
      Can't follow you. Pline contains always >= 2 vertices.

      Cheers
     
    Jürg Menzi, Sep 10, 2004
    #6
  7. Jürg Menzi

    moshe Guest

    Ok Jurg

    Thank you very much, now it is working.

    "What do you mean with 'viritual object'? Temporary object?"
    Yes, temporary object...

    moshe


     
    moshe, Sep 10, 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.