Author Topic: invalid index  (Read 2070 times)

0 Members and 1 Guest are viewing this topic.

ronjonp

  • Needs a day job
  • Posts: 7531
invalid index
« on: July 13, 2007, 05:08:24 PM »
Why would objects really far away from 0,0 cause this code to bonk out?

Code: [Select]
  (vlax-safearray->list
    (vlax-variant-value
      (vla-intersectwith
(vlax-ename->vla-object (car (entsel)))
(vlax-ename->vla-object (car (entsel)))
acExtendBoth
      )
    )
  )

Thanks,

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

LE

  • Guest
Re: invalid index
« Reply #1 on: July 13, 2007, 05:31:04 PM »
Hi Ron;

Can you wrap your code with vl-catch-all-xxx like:

Code: [Select]
    (if (not
  (vl-catch-all-error-p
    (setq value (vl-catch-all-apply
  'vlax-safearray->list
  (list
    (vlax-variant-value
      (vla-intersectwith
obj1
obj2
acextendboth)))))))

then see if works.

ronjonp

  • Needs a day job
  • Posts: 7531
Re: invalid index
« Reply #2 on: July 13, 2007, 07:34:46 PM »
Thanks LE....I ended up using inters and it fixed my problem.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: invalid index
« Reply #3 on: July 13, 2007, 07:56:43 PM »
Ron,

How about this ?
Code: [Select]
(VLAX-INVOKE (VLAX-ENAME->VLA-OBJECT (CAR (ENTSEL)))
             "intersectwith"
             (VLAX-ENAME->VLA-OBJECT (CAR (ENTSEL)))
             ACEXTENDBOTH
)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: invalid index
« Reply #4 on: July 13, 2007, 08:53:56 PM »
Ron,
Not really off Topic :

Are both objects selected lines (or straignt polylines) rather than any other object.

A little known factoid about  the IntersectWith Method is that it will return ALL intersections for curved objects.
For instance draw 2 intersecting circles and run the code I posted ( or your initial code)

Code: [Select]
(SETQ datalist (VLAX-INVOKE (VLAX-ENAME->VLA-OBJECT (CAR (ENTSEL)))
                            "intersectwith"
                            (VLAX-ENAME->VLA-OBJECT (CAR (ENTSEL)))
                            ACEXTENDBOTH
               )
)

With My code you will get something like
(44407.4 3271.38 0.0 42033.4 6814.93 0.0)
... just a collection of reals ..

Run it through a translator like this ;
Code: [Select]
(DEFUN kdub:datalist->points (datalist sublistSize / tmp return Index)
    (SETQ Index 0)
    (FOREACH var datalist
        (SETQ tmp (APPEND tmp (LIST var)))
        (IF (ZEROP (REM (SETQ Index (1+ Index)) sublistSize))
            (SETQ return (CONS tmp return)
                  tmp    nil
            )
        )
    )
    (REVERSE return)
)


(kdub:datalist->points datalist 3)
Will return ALL the intersection points, something like
((44407.4 3271.38 0.0) (42033.4 6814.93 0.0))


... has some possibilities, heh?



kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: invalid index
« Reply #5 on: July 13, 2007, 10:23:54 PM »
Ron,
or something like this may be more efficient as a translator ...
I've used this functionality to interrogate intersection between a line (say) and a block.
Code: [Select]
(DEFUN kdub:datalist->Coordinates (datalist / coordinates)
    (IF (> (LENGTH datalist) 3)
        (WHILE (CADDR datalist)
            (SETQ coordinates (CONS (LIST (CAR datalist)
                                          (CADR datalist)
                                          (CADDR datalist)
                                    )
                                    coordinates
                              )
                  datalist    (CDDDR datalist)
            )
        )
        ;; else
        (SETQ coordinates datalist)
    )
    coordinates
)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

ronjonp

  • Needs a day job
  • Posts: 7531
Re: invalid index
« Reply #6 on: July 14, 2007, 12:10:08 PM »
Kerry,

Thanks for all your replies..I'll mess around with these on Monday :) Have a nice weekend.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC