Author Topic: Danger Will Robinson ....  (Read 3551 times)

0 Members and 1 Guest are viewing this topic.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Danger Will Robinson ....
« on: June 09, 2005, 03:07:50 PM »
... just woke up with a blinding insight ..
I spent a couple of hours yesterday trying to find "one of those" bugs that are intermittent.

If you haven't seen this one before, It MAY take a little finding.
The example is of course fabricated for this exercise ...
Code: [Select]
 (setq ms      (vla-get-modelspace
                  (vla-get-activedocument (vlax-get-acad-object))
                )
        oPline  (vlax-invoke ms
                             'AddLightweightPolyline
                             '(0.0 0.0 200.0 0.0 200.0 100.0 0.0 100.0)
                )
        xoPline (vlax-invoke ms
                             'AddLightweightPolyline
                             '(0.0 0.0 200 0.0 200 100 0.0 100)
                )
  )


The input vertex data needs to be reals. Ints are NOT acceptable.
When you stop to think about it in hindsight, the ActiveX method requires a double, so ..
tuck this away, it may save your sanity one day  

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

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Danger Will Robinson ....
« Reply #1 on: June 09, 2005, 03:22:05 PM »
Thanks Kerry.

Favorites.Add This ;
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Danger Will Robinson ....
« Reply #2 on: June 09, 2005, 03:29:23 PM »
Interesting, especially since I almost always use this approach rather than the vla-add.......

But, when using the other method you CAN use INT's in your list...:
Code: [Select]

(setq ptList '(0.0 0.0 200 0.0 200 100 0.0 100)
      coords (vlax-safearray-fill
      (vlax-make-safearray
vlax-vbdouble
(cons 0 (- (length ptList) 1))
)
      ptList
      )
      xopline (vla-addlightweightpolyline ms coords)
      )

Jürg Menzi

  • Swamp Rat
  • Posts: 599
  • Oberegg, Switzerland
Danger Will Robinson ....
« Reply #3 on: June 10, 2005, 01:51:58 AM »
Hi Jeff
Quote from: Jeff_M
But, when using the other method you CAN use INT's in your list...:
That's because you define an array of doubles. In this case Int's are converted automatically...
And how about:
Code: [Select]
(cons 0 (1- (length ptList)))
 :wink:
Cheers
A computer's human touch is its unscrupulousness!
MENZI ENGINEERING GmbH
Current A2k16... A2k24 - Start R2.18

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Danger Will Robinson ....
« Reply #4 on: June 10, 2005, 02:25:53 AM »
Quote from: Jeff_M
>>> since I almost always use this approach rather than the vla-add.......
 <<<


I have a preference for invoking rather than the 'vla-add... as well Jeff.

Interestingly, this issue is rare, 'cause most vertex data is passed from extractions or getpoint type sources.
One variation of this just happened to be fed unaudited Integers.
... It doesn't any longer
:)
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>
Danger Will Robinson ....
« Reply #5 on: June 10, 2005, 02:34:25 AM »
While we are looking at 'gotcha's ..

Code: [Select]
(setq ActiveUcs (vla-get-activeucs g:activedoc))
 The current UCS MUST be named for this to work as documented. This one can also cause an intermittent death trap.

.. and in case you're wondering,
I'm working on drawing parametric 3D stuff.
Lots of LWPlines and regions in 3D space, on Dynamic UCS's.

(vla-transformby ... is my friend
Aren't Matrix calcs fun :)
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>
Danger Will Robinson ....
« Reply #6 on: June 10, 2005, 07:33:31 AM »
and ..
Quote
While we are looking at 'gotcha's ..  

This may solve that issue.
Would anyone care to run this around for a while, and see if it breaks.

First, some basic library stuff to save typing :
Code: [Select]

;;;;----------------
;;; Local ActiveX variables for testing
;;;; IAcadApplication Object
;;
  (or g:acadapp
      (setq g:acadapp (vlax-get-acad-object))
  )
;;;; IAcadDocument Object
;;
  (or g:activedoc
      (setq g:activedoc (vla-get-activedocument g:acadapp))
  )
;;;; IAcadModelSpace Object
;;
  (or g:modelspace
      (setq g:modelspace (vla-get-modelspace g:activedoc))
  )
;;;; IAcadUCSs Collection
;;
  (or g:ucss
      (setq g:ucss (vla-get-usercoordinatesystems g:activedoc))
  )

;;;;----------------

Then the gory details
Code: [Select]
;;;;----------------
;; c:TestUCSBuilder
;; by Kerry Brown  2005.Jun.10
;; Test routine to use ActiveX methods to Name the Current UCS
;; and to Make it Active.
;; This will then permit calls which only work for a Named UCS.
;;    ie: (setq TempUCS (vla-get-activeucs g:activedoc) )
;;     (setq TempUCSMatrix (vla-getucsmatrix TempUCS)
;;           and will then  give access to vla-transformby ...
;;    The principle is to define the UCS at 0,0,0 , using the vectors
;; from the original definition as Points. The Origin is then relocated.
;; This principle methodology could be incorporated into a BlackBox
;; for building new UCS's
;; ie: passed the  NewUcsName Origin XPoint YPoint

(defun c:TestUCSBuilder (/ Origin localUCS)
  (setq Origin   (getvar "ucsorg")
        localUCS (vla-add g:ucss
                          (vlax-3d-point '(0.0 0.0 0.0))    ;origin
                          (vlax-3d-point (getvar "ucsxdir")) ;x-axis
                          (vlax-3d-point (getvar "ucsydir")) ;y-axis
                          "_TempUCS"
                 )
  )
  (vla-put-origin localUCS (vlax-3d-point Origin))
  (vla-put-activeucs g:activedoc localUCS)
  localUCS
)
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.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Danger Will Robinson ....
« Reply #7 on: June 10, 2005, 08:09:18 AM »
Worked here, ACAD2000, Windows 2000
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Danger Will Robinson ....
« Reply #8 on: June 10, 2005, 12:59:44 PM »
Quote from: Jürg Menzi
Hi Jeff
Quote from: Jeff_M
But, when using the other method you CAN use INT's in your list...:
That's because you define an array of doubles. In this case Int's are converted automatically...
And how about:
Code: [Select]
(cons 0 (1- (length ptList)))
 :wink:
Cheers

Hi Jürg,
I must admit that I ripped that little (safearray-fill....) code out of something else written by a former co-worker and I never really looked at the internal parts  :oops:

As for the int->double, I know that the array is defined so the INT gets converted....but since we can pass a list to (vlax-invoke ms 'addlwpline), why won't it autoconvert the INT's? It converts to a safearray just fine providing you use doubles......IOW, if one method will autoconvert, why not the other?

Of course, that's what happens when we use undocumented methods  :)