Author Topic: Enum Symbol Arithmetic Possible?  (Read 2629 times)

0 Members and 1 Guest are viewing this topic.

Lee Mac

  • Seagull
  • Posts: 12927
  • London, England
Enum Symbol Arithmetic Possible?
« on: December 30, 2009, 07:15:54 PM »
Just a quick one,

I was trying to create a quick toggle, using this kind of arrangement:

Code: [Select]
(vlax-put-property obj (1- (abs (vlax-get-property obj))))

But even using such functions as "read" or "eval" in this arrangement, I cannot get the symbol (such as :vlax-true) into its enum form.

Can this be done?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Enum Symbol Arithmetic Possible?
« Reply #1 on: December 30, 2009, 09:53:12 PM »
So you are stuck with this?
Code: [Select]
(vlax-put-property obj (if (= (vlax-get-property obj) :vlax-true):vlax-false :vlax-true))
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.

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Enum Symbol Arithmetic Possible?
« Reply #2 on: December 31, 2009, 01:51:24 AM »
or maybe something like
Code: [Select]
(vlax-put-property obj (if (zerop (vlax-get-property obj))-1 0))
no acad available to test on so just wingin it

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Lee Mac

  • Seagull
  • Posts: 12927
  • London, England
Re: Enum Symbol Arithmetic Possible?
« Reply #3 on: December 31, 2009, 07:27:27 AM »
So you are stuck with this?
Code: [Select]
(vlax-put-property obj (if (= (vlax-get-property obj) :vlax-true):vlax-false :vlax-true))

Exactly, but you know me - I like the elegant solutions :-)

Lee Mac

  • Seagull
  • Posts: 12927
  • London, England
Re: Enum Symbol Arithmetic Possible?
« Reply #4 on: December 31, 2009, 07:35:59 AM »
or maybe something like
Code: [Select]
(vlax-put-property obj (if (zerop (vlax-get-property obj))-1 0))
no acad available to test on so just wingin it

Sorry Ron

Code: [Select]
; error: bad argument type: numberp: :vlax-false

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Enum Symbol Arithmetic Possible?
« Reply #5 on: December 31, 2009, 08:24:27 AM »
or maybe something like
Code: [Select]
(vlax-put-property obj (if (zerop (vlax-get-property obj))-1 0))
no acad available to test on so just wingin it

Sorry Ron

Code: [Select]
; error: bad argument type: numberp: :vlax-false

DOH  :-P

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Enum Symbol Arithmetic Possible?
« Reply #6 on: December 31, 2009, 08:32:38 AM »
for academia:

Code: [Select]
(progn

    (setq layer
        (vla-item   
            (vla-get-layers
                (vla-get-activedocument
                    (vlax-get-acad-object)
                )
            )
            "0"
        )
    )
   
    (setq property 'lock)
   
    (vlax-put layer property
        (if (zerop (vlax-get layer property))
           -1
            0
        )   
    )
   
)

however, in practice it's of little value imo
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Lee Mac

  • Seagull
  • Posts: 12927
  • London, England
Re: Enum Symbol Arithmetic Possible?
« Reply #7 on: December 31, 2009, 08:34:12 AM »
Gotcha - cheers Michael  :-)

Lee Mac

  • Seagull
  • Posts: 12927
  • London, England
Re: Enum Symbol Arithmetic Possible?
« Reply #8 on: December 31, 2009, 08:35:58 AM »
For those interested in how I used it:

Code: [Select]
(defun c:dtog nil
  (vl-load-com)

  (vla-StartUndoMark
    (cond (*doc*) ((setq *doc* (vla-get-ActiveDocument
                                 (vlax-get-acad-object))))))

  (vlax-for obj (vla-get-Block (vla-get-ActiveLayout *doc*))
                 
    (if (vl-position
          (vla-get-ObjectName obj)
          '("AcDbRotatedDimension" "AcDb2LineAngularDimension"
            "AcDbAlignedDimension" "AcDb3PointAngularDimension" "AcDbArcDimension"))
     
      (mapcar
        (function
          (lambda (x)
            (vlax-put obj x (1- (abs (vlax-get obj x))))))
       
        '(ExtLine1Suppress ExtLine2Suppress))))

  (vla-EndUndoMark *doc*)
  (princ))

JohnK

  • Administrator
  • Seagull
  • Posts: 10664
Re: Enum Symbol Arithmetic Possible?
« Reply #9 on: December 31, 2009, 09:57:31 AM »
NOT!
I'm positive, that joke will be funny when you get to the code part. And if it isnt, blame the 90's.

A little obscure but seeing as its just for academia.

Using MP's example.
Code: [Select]
(progn

    (setq layer
        (vla-item  
            (vla-get-layers
                (vla-get-activedocument
                    (vlax-get-acad-object)
                )
            )
            "0"
        )
    )
    
    (setq property 'lock)
    
    (vlax-put layer property
     
;;;        (if (zerop (vlax-get layer property))
;;;           -1
;;;            0
;;;        )
  (~ (vlax-get layer property))
    )
)
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Lee Mac

  • Seagull
  • Posts: 12927
  • London, England
Re: Enum Symbol Arithmetic Possible?
« Reply #10 on: December 31, 2009, 11:06:59 AM »
Haha! Very nice Se7en..!  :-)