Author Topic: Help Desperately Needed  (Read 5766 times)

0 Members and 1 Guest are viewing this topic.

nlanum

  • Guest
Help Desperately Needed
« on: July 01, 2010, 06:56:56 PM »
I have some custom tools that were developed for ACAD 2007.

When we upgraded to ACAD 2010, the tools did not work anymore.
I paid a company to make it work for ACAD 2010 and everything was working fine. Now, we have upgraded to ACAD 2011 and the tools do not work anymore. I get an error stating "incompatible autocad version". Will someone please look at the following code and see if we can make it work for ACAD 2011.

These are the only changes that I can see that were made to make this work for ACAD 2010. I need this to work in ACAD 2011.

Thanks in advance.

Norm
Code: [Select]
--------------------------------
;;; **** Replace function in VLX for compatability with 2010+
(defun ZF_GET-ACADCOLOR ()
  (VL-LOAD-COM)
  (setq ZF_ACADCOLOR
(vla-GetInterfaceObject
   (ZF_GET-ACAD-OBJECT)
   (strcat "AutoCAD.AcCmColor."
   (itoa (ATOI (GETVAR "ACADVER")))
   )
)
  )
)
;;; **** Additional function for Ribbon deployment
(defun setupInsReactor (props)
  (setq lke (entlast))
  (setq insEnd:cmdreactor
   (vlr-Command-Reactor
     nil
     '((:vlr-CommandEnded . InsertDynamic))
   )
insCan:cmdreactor
   (vlr-Command-Reactor
     nil
     '((:vlr-commandCancelled . killReactor))
   )
insFail:cmdreactor
   (vlr-Command-Reactor
     nil
     '((:vlr-commandCancelled . killReactor))
   )
Savedprops    props
  )
  (prompt "\nReactors setted.")
)
(defun EDIINSERT (lay blk scl ang props)
  (EDISETLAYER lay)
  (if props
    (setupInsReactor props)
  )
  (command "-insert" blk)
  (if (= "*" (substr blk 1 1))
    (progn
      (command (setq ip (getpoint)))
      (if scl
(command scl)
(command (getdist ip))
      )
      (if ang
(command ang)
(command (getangle ip))
      )
    )
    (progn
      (if scl
(command "S" scl)
      )
      (if ang
(command "R" ang)
      )
    )
  )
)

(defun EDISETLAYER (lay)
  (if (not (tblsearch "layer" lay))
    (progn
      (prompt (strcat "*** Layer " lay " does not exist! ***"))
      (command "-layer" "m" lay "")
    )
  )
  (command "-layer" "s" lay "")
)
(defun asmi-LayersStateRestore (StateList)
  (foreach lay StateList
    (vla-put-Lock (car lay) (cadr lay))
  )
  (princ)
)
; Insert Call Back
(defun InsertDynamic (callReact cmdArgs)
  (if (or (= (car cmdArgs) "INSERT")
  (= (car cmdArgs) "-INSERT")
      )
    (progn
      (if (/= lke (entlast))
(progn
;(alert "I was triggered")
  (foreach p Savedprops
    (SetDynProp (entlast) (car p) (cadr p))
  )
  (setq lke (entlast))
)
      )
      (killReactor nil nil)
    )
  )
)

(defun killReactor (callReact cmdArgs)
  (vlr-remove-all :vlr-Command-Reactor)
  (if insEnd:cmdreactor
    (progn (vlr-remove insEnd:cmdreactor)
   (setq insEnd:cmdreactor nil)
    )
  )
  (if insCan:cmdreactor
    (progn (vlr-remove insCan:cmdreactor)
   (setq insCan:cmdreactor nil)
    )
  )
  (if insFail:cmdreactor
    (progn (vlr-remove insFail:cmdreactor)
   (setq insFail:cmdreactor nil)
    )
  )
  (prompt "\nReactors cleared.")
)
(defun SetDynProp (e propname newval / obj v vval sal tot i)
  (setq obj (if (= (type e) 'vla-object)
      e
      (vlax-ename->vla-object e)
    )
  )
  (if (= (vlax-get-property obj 'isdynamicblock) :vlax-true)
    (progn
      (setq v (vla-getdynamicblockproperties obj)
    vval (vlax-variant-value v)
    sal (vlax-safearray->list vval)
    tot (length sal)
    i 0
      )
      (while (< i tot)
(if (= (vlax-get-property (nth i sal) "PropertyName") propname)
  (progn
    (vlax-put-property (nth i sal) "Value" newval)
    (setq i tot)
  )
  (setq i (1+ i))
)
      )
    )
  )
)

[code tags and formatting added :kdub]
« Last Edit: July 01, 2010, 07:35:58 PM by Kerry Brown »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Help Desperately Needed
« Reply #1 on: July 01, 2010, 07:33:48 PM »
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.

Hangman

  • Swamp Rat
  • Posts: 566
Re: Help Desperately Needed
« Reply #2 on: July 01, 2010, 07:46:35 PM »
First off, welcome to the swamp.
Secondly, when you are posting code, there's an icon that looks like the # symbol.  This is for code.  The way you have it currently posted makes it hard to read.
Thirdly, when creating a new post, try and make the title more appropriate to the topic of the code.

Anyway, don't mind me, I'm just passing along what was told me over and over again.


So, how much do you know about LiSP ??

< ... >
;;; **** Replace function in VLX for compatability with 2010+
(defun ZF_GET-ACADCOLOR ()
(VL-LOAD-COM)
(setq ZF_ACADCOLOR
(vla-GetInterfaceObject
(ZF_GET-ACAD-OBJECT)
(strcat "AutoCAD.AcCmColor."
(itoa (ATOI (GETVAR "ACADVER")))
)
)
)
)
 < ... >

The item listed in red in the quote is telling us that the program is searching for the ACAD version.  I can't see where it is checking this version against the program though.  I would assume there's a piece of code somewhere that will check the version against something and if the current ACAD version does not match, it kicks it out or stops running.

I would also think whoever wrote it is trying to confuse the reader for some reason.  
Code: [Select]
([color=red]itoa (ATOI (GETVAR "ACADVER"[/color])))

itoa = Integer to string conversion
atoi = string to integer conversion

So this is being converted to integer and back to string in one line.

Perhaps I am wrong in this assumption and would appreciate others sounding off on my contribution here.


< edited >  You should also recognize the one who wrote the code regardless of their current affiliation.
« Last Edit: July 01, 2010, 07:50:08 PM by Hangman »
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Help Desperately Needed
« Reply #3 on: July 01, 2010, 07:52:17 PM »

nlanum ,

Welcome to theSwamp.

Just a couple of points.

It would help if you were to :

Indicate where the error happens.
Provide ALL functions so that anyone choosing to test can do so.
Provide some sort of explaination as to what the routine function is ( ie what are your expectations)

Not everyone is prepared to just run unknown code, nor have the time to decipher code that is a little complicated.
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: Help Desperately Needed
« Reply #4 on: July 01, 2010, 07:57:59 PM »


I don't think this is what you want to use.

Command: (GETVAR "ACADVER")
;;==>> "18.1s (LMS Tech)"

won't you just want the "18"

try something like  (read  (GETVAR "ACADVER"))
;;==>> "18"
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.

nlanum

  • Guest
Re: Help Desperately Needed
« Reply #5 on: July 01, 2010, 08:07:48 PM »
Thank you for the comments about the proper etiquette for posting here.
I do appreciate it.

I can't find the string that you just posted.

I don't think this is what you want to use.

Code: [Select]
I don't think this is what you want to use.

Command: (GETVAR "ACADVER")
;;==>> "18.1s (LMS Tech)"

won't you just want the "18"

try something like  (read  (GETVAR "ACADVER"))
;;==>> "18"


I am attaching all the files in hopes that someone can save my a##.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Help Desperately Needed
« Reply #6 on: July 01, 2010, 08:17:16 PM »

actually, thinking aboit it these 2 are equivalent

(read  (GETVAR "ACADVER"))
(itoa (ATOI (GETVAR "ACADVER")))
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: Help Desperately Needed
« Reply #7 on: July 01, 2010, 08:19:46 PM »
I'm not prepared to run a VLX fron an untrusted source  .. sorry


however the problem isn't with the assignment to ZF_ACADCOLOR
Code: [Select]

 (setq ZF_ACADCOLOR
(vla-GetInterfaceObject
  (vlax-get-acad-object)
  (strcat "AutoCAD.AcCmColor."
  (itoa (ATOI (GETVAR "ACADVER")))
  )
)
  )

Returns
;;==>> #<VLA-OBJECT IAcadAcCmColor 000000002ba9f840>

(vlax-dump-Object ZF_ACADCOLOR T)

; IAcadAcCmColor: AutoCAD AcCmColor Interface
; Property values:
;   Blue (RO) = 0
;   BookName (RO) = ""
;   ColorIndex = 256
;   ColorMethod = 192
;   ColorName (RO) = ""
;   EntityColor = -1073741824
;   Green (RO) = 0
;   Red (RO) = 0
; Methods supported:
;   Delete ()
;   SetColorBookColor (2)
;   SetNames (2)
;   SetRGB (3)
« Last Edit: July 01, 2010, 08:24:59 PM by Kerry Brown »
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.

Hangman

  • Swamp Rat
  • Posts: 566
Re: Help Desperately Needed
« Reply #8 on: July 02, 2010, 10:47:34 AM »
I'm not prepared to run a VLX fron an untrusted source  .. sorry

however the problem isn't with the assignment to ZF_ACADCOLOR
Code: [Select]

 (setq ZF_ACADCOLOR
(vla-GetInterfaceObject
   (vlax-get-acad-object)
   (strcat "AutoCAD.AcCmColor."
   (itoa (ATOI (GETVAR "ACADVER")))
   )
)
  )
< ... >

I agree with you Kerry, the problem is not with ZF_ACADCOLOR.  But like you pointed out,

actually, thinking aboit it these 2 are equivalent

(read  (GETVAR "ACADVER"))
(itoa (ATOI (GETVAR "ACADVER")))

These are equivalent.  It is simply getting the version of autocad here.  But according to the dump you posted, it's not even showing a version number to test against.  And it's not showing a variable to hold it either.
Which tells me this is merely fluff to confuse someone trying to edit the code.  There is probably a legitimate test in the VLX, so unless there is a hacker willing to crack open the VLX to get to the code, what do you do now ??
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Help Desperately Needed
« Reply #9 on: July 02, 2010, 10:50:40 AM »
< .. >  what do you do now ??

go to bed .
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.

Jeff_M

  • King Gator
  • Posts: 4099
  • C3D user & customizer
Re: Help Desperately Needed
« Reply #10 on: July 02, 2010, 11:56:25 AM »
And it's not showing a variable to hold it either. Which tells me this is merely fluff to confuse someone trying to edit the code.
Not that this helps solve the riddle with the rest of the code, but thought I'd chime in on this one little part...It's not being set to a variable or even checked for anything. It is all a part of one line:
Code: [Select]
(setq ZF_ACADCOLOR
(vla-GetInterfaceObject
   (vlax-get-acad-object)
   (strcat "AutoCAD.AcCmColor."
   (itoa (ATOI (GETVAR "ACADVER")))
   )
)
  )

;;is the same as
(setq ZF_ACADCOLOR (vla-GetInterfaceObject (vlax-get-acad-object) (strcat "AutoCAD.AcCmColor." (itoa (ATOI (GETVAR "ACADVER"))))))
IOW, the version number is just being appended to "AutoCAD.AcCmColor.", which Kerry showed is working.

Jeff_M

  • King Gator
  • Posts: 4099
  • C3D user & customizer
Re: Help Desperately Needed
« Reply #11 on: July 02, 2010, 12:23:51 PM »
Well, I went ahead and loaded the EDI menu after adding the unzipped path to my support files paths. It all works just fine, except the dwg's for the blocks in the toolbar were not included in the zip. All the one's I tested in the Ribbon appear to be just fine. I never get any version incompatibility error.

nlanum

  • Guest
Re: Help Desperately Needed
« Reply #12 on: July 02, 2010, 12:28:11 PM »
Jeff-

Thank you for the efforts.
Did you run this in acad 2011?

Hangman

  • Swamp Rat
  • Posts: 566
Re: Help Desperately Needed
« Reply #13 on: July 02, 2010, 12:39:25 PM »
< ... >
;;is the same as
Code: [Select]
(setq ZF_ACADCOLOR (vla-GetInterfaceObject (vlax-get-acad-object) (strcat "AutoCAD.AcCmColor." (itoa (ATOI (GETVAR "ACADVER"))))))IOW, the version number is just being appended to "AutoCAD.AcCmColor.", which Kerry showed is working.

OK, now you have my increasing interest so I need to ask;
First, what IS the purpose (do you believe) of the line
Code: [Select]
(itoa (ATOI (GETVAR "ACADVER")))  As Kerry pointed out and to my understanding, its redundant.
Second, where is it being appended to ??  The closest point I can see would be the "EntityColor = -1073741824", but that's not making any sense to me.  Of course, APPEND simply takes two lists and combines them into one and when Kerry dumped the object, did it not read the 'acadver' ??  Or perhaps I should ask, How is this Appending these two items together working ??
Third, why would this be appended to the "AutoCAD.AcCmColor" ??

I know all this isn't going to help much, but I am curious, this is getting interesting.
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

nlanum

  • Guest
Re: Help Desperately Needed
« Reply #14 on: July 02, 2010, 12:43:36 PM »
here are a couple more files that I found.

EDI.fas

I have no idea what it is but in the folder I found it there was mention to the EDI.vlx file.