Get items in VBA and then pass to LISP selection set?

Discussion in 'AutoCAD' started by terencechatfielduk, Aug 18, 2003.

  1. I'm trying to write a routine that will prompt the user to select a group of items, which will be checked in VBA for correctness of type, and then pass this lisp to LISP where it will be processed. The sort of simple thing i am trying to do (as a testbed/evaluation-of-the-concept-process) is to pick an object and then delete it. I can get it to work in only LISP easily enough, but with VBA i can pick the object, and create the LISP selection set with no probs, but can't seem to pass any information to LISP itself. I though perhaps the objectID could be used, but even though its the equivalent of the objects LISP-entity name, it won't recognise it. I'm guessing that I can't set a LISP symbol to an object name or anything else that VBA could pass, as i don't even seem to be able to do it from the autocad command line. Is this correct, or does anyone have any tips?
     
    terencechatfielduk, Aug 18, 2003
    #1
    1. Advertisements

  2. terencechatfielduk

    Ed Jobe Guest

    Here's a function I wrote.

    Public Function Ent2lspEnt(entObj As AcadEntity) As String
    'Designed to work with SendCommand, which can't pass objects.
    'This gets an objects handle and converts it to a string
    'of lisp commands that returns an entity name when run in SendCommand.
    Dim entHandle As String
    entHandle = entObj.Handle
    Ent2lspEnt = "(handent " & Chr(34) & entHandle & Chr(34) & ")"
    End Function
     
    Ed Jobe, Aug 18, 2003
    #2
    1. Advertisements

  3. You can delete an object quite easily from VBA. Why involve LISP?




    --
    There are 10 kinds of people. Those who understand binary and those who don't.



     



    http://code.acadx.com




    <terencechatfielduk> wrote in message news:...

    I'm trying to write a routine that will prompt the user to select a group of items, which will be checked in VBA for correctness of type, and then pass this lisp to LISP where it will be processed. The sort of simple thing i am trying to do (as a testbed/evaluation-of-the-concept-process) is to pick an object and then delete it. I can get it to work in only LISP easily enough, but with VBA i can pick the object, and create the LISP selection set with no probs, but can't seem to pass any information to LISP itself. I though perhaps the objectID could be used, but even though its the equivalent of the objects LISP-entity name, it won't recognise it. I'm guessing that I can't set a LISP symbol to an object name or anything else that VBA could pass, as i don't even seem to be able to do it from the autocad command line. Is this correct, or does anyone have any tips?
     
    Frank Oquendo, Aug 18, 2003
    #3
  4. Thanks Ed, that works great. I'm wanting to use this to write a function that uses the autocad 'subtract' command for 3d solids, but which copies the solid that will be subtracted before it does the subtract. I can't figure out how this is supposed to be done in VBA, so i was going to do what i needed in VBA first then just finish it off in LISP.
     
    terencechatfielduk, Aug 19, 2003
    #4
  5. terencechatfielduk

    Ed Jobe Guest

    In lisp you would issue:



    (command "subtract" ss1 ss2).



     



    In vba you would use:



    ThisDrawing.SendCommand "subtract " & Ent2lspEnt(ss1) & " " & Ent2LspEnt(ss2)




    --
    Ed
    --




    <terencechatfielduk> wrote in message news:...

    Thanks Ed, that works great. I'm wanting to use this to write a function that uses the autocad 'subtract' command for 3d solids, but which copies the solid that will be subtracted before it does the subtract. I can't figure out how this is supposed to be done in VBA, so i was going to do what i needed in VBA first then just finish it off in LISP.
     
    Ed Jobe, Aug 19, 2003
    #5
  6. Terence,
    I've found the easiest, if not most elegant way to send entities to a
    command like subtract is to *not* attempt to make a LISP selection set at
    all.

    Instead, I would just loop through my VBA selection set (or array of
    objects, or collection, or whatever) and build a SendCommand string with a
    "Ent2lspEnt" for each object and spaces or vbCR's scattered appropriately.
    It seems robust enough for my needs so far.... and since it's the only way I
    know to build a LISP selection set, the LISP sset becomes redundant.

    Just my opinyun,
    James
     
    James Belshan, Aug 19, 2003
    #6
  7. The Acad3DSolid class has a Copy method which will create a duplicate solid. You can then use the Boolean method to perform your operation.




    --
    There are 10 kinds of people. Those who understand binary and those who don't.



     



    http://code.acadx.com




    <terencechatfielduk> wrote in message news:...

    Thanks Ed, that works great. I'm wanting to use this to write a function that uses the autocad 'subtract' command for 3d solids, but which copies the solid that will be subtracted before it does the subtract. I can't figure out how this is supposed to be done in VBA, so i was going to do what i needed in VBA first then just finish it off in LISP.
     
    Frank Oquendo, Aug 19, 2003
    #7
  8. terencechatfielduk

    Ed Jobe Guest

    I didn't think of that. I just did a straight translation. SS's wouldn't need a handle since they are not stored in the dwg. You could always use vlax.cls from acadx.com and keep the lisp syntax.



    There might be other vba methods for working with solids, but I don't normally do much with them, so I'm not the best one to ask. The subtract command might accept two single objects instead of two ss's. Then you could use the syntax I provided. Give it a try.
    --
    Ed
    --




    <terencechatfielduk> wrote in message news:...

    I assume that VBA selection sets can't be used, only those created in LISP? I looked to see if they have a handle that could be passed but couldn't find one.
     
    Ed Jobe, Aug 19, 2003
    #8
  9. Ed, the syntax works fine with single objects...but if I'd known about the boolean method I would have used it instead of going to LISP. There I was thinking there was method for subtracting solids in VBA...Still, useful stuff to know how to do in LISP, when VBA doesn't have a method available.
     
    terencechatfielduk, Aug 19, 2003
    #9
    1. Advertisements

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.