Author Topic: checking in lisp  (Read 8184 times)

0 Members and 1 Guest are viewing this topic.

daron

  • Guest
checking in lisp
« on: November 25, 2003, 06:13:32 PM »
I ran the check edit window in vlide on this:
Code: [Select]
(defun array->list (arrayproperty)
 (vlax-safearray->list
      (vlax-variant-value
       (arrayproperty
        LayoutObj
       )
      )
 )
)

and received this:
Code: [Select]
; warning: local variable used as function: ARRAYPROPERTY
Is this because of the limited ability of the editor, or have I done something wrong? The code is nested in another defun.

This is LayoutObj, just in case you were wondering:
Code: [Select]
(vla-get-ActiveLayout $doc)

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
checking in lisp
« Reply #1 on: November 25, 2003, 07:18:35 PM »
That would depend upon your heirarchy for the arrayproperty call.

just by the looks of it, you are passing a function (arrayproperty) as an argument to the function array->list

If this in your intention, then you may or may not experience some issues, depending upon how the lisp interpreter evaluates the variable arrayproperty
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

daron

  • Guest
checking in lisp
« Reply #2 on: November 26, 2003, 12:10:28 AM »
Arrayproperty could be any property that uses the layoutobject. I believe only plotting properties use this and that is the intended purpose. So, yes, it would be a functoin passed as an argument. Doing this really sped things up in testing. Passing a function in this way seems to me like a good idea. Is it not?

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
checking in lisp
« Reply #3 on: November 26, 2003, 04:34:30 AM »
Daron : I may just be having a bad day ..

You say this "sped things up in testing."

I believe that the only property of an IAcadLayout object that is returned as a variant is the PlotOrigin property
.. so the use would be restricted to one property of the 30 {or so } associated with the object.


To make your function work, I believe you would have to change it to use ( EVAL ... ) as shown here.

Perhaps I am mis-understanding your intention here.

< added kwb > btw.  using eval like this eliminates the code-check warning, as well as allowing the routine to function properly.
Code: [Select]

(setq LayoutObj (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))

(defun array->list   (arrayproperty)
     (vlax-safearray->list
          (vlax-variant-value
              ((eval arrayproperty)
                 LayoutObj

                  )
          )
     )
)

Then :--
(array->list 'vla-get-PlotOrigin)

;; returns ==>> (23.62 0.0)

(array->list 'vla-get-ConfigName)

;; returns  ==>> ; error: bad argument type: variantp "PostScript Level 2.pc3"
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.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
checking in lisp
« Reply #4 on: November 26, 2003, 06:48:02 AM »
Kerry, I do believe you are right, however suppose there is another function defined as arrayproperty then there would be no problem. Here again it depends upon the evaluation of the arrayproperty variable.

If the arrayproperty variable indeed holds a function i.e. (defun thiscommand .....) then the user passes that command to the array->list command i.e. (array->list thiscommand), then in the array->list function thiscommand is put directly into arrayproperty and it would be evaluated without having to use the (eval....) preceeding it.

If the variable passed was a member function of an object, then it is likely the (eval....) would need to be there.

Any thought on that Daron?
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
checking in lisp
« Reply #5 on: November 26, 2003, 08:01:53 AM »
KEB:
It's a guessing game untill we have an example of how Daron expects this function to be called.
.. I just took best guess.

With this type of functionality there are 2 issues.
Can you do it this way.
Do you want to.

That's Darons call.

Personally I would keep it simple and transparent.
The IAcadLayout has already been defined, so all that is needed is an in line call to :
;; return the translated Variant (two-element array of doubles)
(vlax-safearray->list (vlax-variant-value (vla-get-PlotOrigin AcadLayout)))

or
;; return an int, long, real, string, enumerator, boolean, Object etc
(vla-get-WhatEverProperty AcadLayout)
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.

daron

  • Guest
checking in lisp
« Reply #6 on: November 26, 2003, 09:18:23 AM »
You say there is only one reason to use this? Here are three others. That makes four.
Code: [Select]
(setq PrinterList (array->list vla-getPlotDeviceNames))
(setq StyleTables (array->list vla-GetPlotStyleTableNames))
(setq PaperSizes (array->list vla-GetCanonicalMediaNames))


I use them to make sure objects exist before calling them, like this:
Code: [Select]
(foreach name PrinterList
 (if (= name "Phoenix ARC.pc3")
      (vla-put-ConfigName
   LayoutObj
   "Phoenix ARC.pc3"
      )
 )
     )

Thanks for the eval idea. I'll give that a shot and see how it goes.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
checking in lisp
« Reply #7 on: November 26, 2003, 09:26:45 AM »
According to the way you have the command array->list using the vlisp commands as arguments you should not need to use eval. In fact it should work exactly like you show AND you should simply ignore that particular warning in this instance.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

daron

  • Guest
checking in lisp
« Reply #8 on: November 26, 2003, 09:32:57 AM »
Thanks Keith.

Anonymous

  • Guest
checking in lisp
« Reply #9 on: November 26, 2003, 09:36:30 AM »
Quote from: Daron
You say there is only one reason to use this? Here are three others. That makes four.
Code: [Select]
(setq PrinterList (array->list vla-getPlotDeviceNames))
(setq StyleTables (array->list vla-GetPlotStyleTableNames))
(setq PaperSizes (array->list vla-GetCanonicalMediaNames))



I make my living by being pedantic.
You were talking about properties.

These are methods.

Ikmow, Iknow ...
 :)

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
checking in lisp
« Reply #10 on: November 26, 2003, 09:37:30 AM »
Yes, It was me :)
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.

daron

  • Guest
checking in lisp
« Reply #11 on: November 26, 2003, 09:47:35 AM »
Sorry, I called it property. OOOOps! Sorry for not being more specific. I am trying. I just don't realize everything that needs to be put forth. It's hard to know what's enough and what's not enough.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
checking in lisp
« Reply #12 on: November 26, 2003, 09:49:47 AM »
That is what initially confused me. Were we discussing a property, which would require an eval or were we discussing a method which would not require an eval?

Eventually the whole story came to light...
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

daron

  • Guest
checking in lisp
« Reply #13 on: November 26, 2003, 09:51:19 AM »
If you mean 'pedantic' by this definition:
Quote
Describes a story in which the moral or message the author wants to teach overwhelms the plot.

Then I must be anti-pedantic.

Sorry for the confusion.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
checking in lisp
« Reply #14 on: November 26, 2003, 10:08:38 AM »
Thats cool :wink:

kwb
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.