TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: KuoTze on April 01, 2014, 08:32:17 AM
-
i work in AutoCad 2015 and run "LeeMAC's CountV1-3.lsp" but it error and msg is ** Error: no function definition: VLA-GET-OBJECTID32 **
How can Fix it ......
Sorry i English is not good to say ~~ please forgive ~~ :embarrassed:
-
The function is obsolete.
I'm not sure how or why it is being used.
Can you test/try the code using VLA-GET-OBJECTID
-
:embarrassed:
i try to fix "vla-get-objetcid32 to vla-get-objetcid"
but can't work and Msg ** Error: ActiveX Server returned the error: unknown name: "SETBLOCKTABLERECORDID32" **
So .... i can't fix it ........
-
Change the function to this:
(defun _getobjectid (doc obj)
(if (and (_is64bit) (= (type vla-get-objectid32) 'subr))
(vla-get-objectid32 obj)
(vla-get-objectid obj)
)
)
And change this portion of the code:
(if (and (_is64bit)
(= (type vla-setblocktablerecordid32) 'subr)
)
'setblocktablerecordid32
'setblocktablerecordid
)
Welcome to TheSwamp :)
-
:-) thank ...
i paste your code to lisp it can't work and msg ** Error: ActiveX Server returned the error: unknown name: "SETBLOCKTABLERECORDID32" **
so ......................
Change the function to this:
(defun _getobjectid (doc obj)
(if (and (_is64bit) (= (type vla-get-objectid32) 'subr))
(vla-get-objectid32 obj)
(vla-get-objectid obj)
)
)
Welcome to TheSwamp :)
-
thank your code
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(if (and (_is64bit)
(= (type vla-setblocktablerecordid32) 'subr)
)
'setblocktablerecordid32
'setblocktablerecordid
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
but ......
now error msg is :
Output [Table/File/Settings] <Exit>:
Specify Point for Table: ; error: Exception occurred: 0xC0000005 (Access Violation)
; warning: unwind skipped on exception
; error: Exception occurred: 0xC0000005 (Access Violation)
it can't work :embarrassed:
-
Give this version a try .. seems to be working on my computer. I noted the change in the header.
-
Thank you so much ...........
Count1.31-RJP can work
Thank you so much ...........
:lmao: :lmao: :lmao:
-
Glad to help :)
-
Many thanks Ron -
I don't have a 64-bit system on which to test the program, so I am incredibly grateful for your assistance.
Lee
-
The function is obsolete.
Hi Kerry,
I wasn't aware that this function had become obsolete in 2015.
Thank you for the information.
Lee
-
It was marked Obsolete in the 2014 Help. I can't confirm 2015 yet.
-
Many thanks Ron -
I don't have a 64-bit system on which to test the program, so I am incredibly grateful for your assistance.
Lee
Anytime Lee :) .. you've helped me a ton.
-
It was marked Obsolete in the 2014 Help. I can't confirm 2015 yet.
Installed 2015 a week ago and that function is gone.
-
Hallo Lee
Here I have ever asked is that no longer work in 2015. :-D
Hier habe ich schon mal gefragt das das nicht mehr funktionieren wird in 2015.
http://www.theswamp.org/index.php?topic=33654.msg513336#msg513336
-
Give this version a try .. seems to be working on my computer. I noted the change in the header.
Ron -
As noted, I unfortunately don't have access to a 64-bit system to test, so I was curious: based on your modifications to the code, does the setblocktablerecordid32 accept a string representation of the 64-bit object ID (as returned by the getobjectidstring method)?
Also, why is the (= (type vla-get-objectid32) 'subr) test not sufficient to cater for 2014 onwards?
Many thanks,
Lee
-
Lee,
From my testing, the setblocktablerecordid32 chucks a wobbly with the x64 objectID string.
_$
_1$
'(vlax-invoke #<VLA-OBJECT IAcadTable 000000002e0bd7f8> SETBLOCKTABLERECORDID32 2 0 "140700197868736" :vlax-true)
_1$
** Error: Out of present range **; reset after error
This test is fine (= (type vla-get-objectid32) 'subr) ... perhaps the function below will suffice :)
(defun _getobjectid (doc obj)
(if (vl-string-search "64" (getenv "PROCESSOR_ARCHITECTURE"))
(if (= (type vla-get-objectid32) 'subr)
(vla-get-objectid32 obj)
(vlax-invoke-method (vla-get-utility doc) 'getobjectidstring obj :vlax-false)
)
(vla-get-objectid obj)
)
)
HTH.
-
Many thanks Ron :-)
-
So will adding Ron's routine and using (_getobjectid docblocks a) instead of (vla-get-objectid32 a) in my routine below work?
(defun _getobjectid (doc obj)
(if (and (_is64bit) (= (type vla-get-objectid32) 'subr))
(vla-get-objectid32 obj)
(vla-get-objectid obj)
)
)
(setq My_block (cdr (assoc 2 (entget FreshInsertedBlock))))
(setq docblocks (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))))
(setq a (vla-item docblocks My_block))
(setq BlockObjectID (vla-get-objectid32 a))
-
Been a long week so I may be overlooking something, but this is the way my brain's working today:
(defun _GetObjectID ( object )
(if vla-get-objectid32
(defun _GetObjectID ( object ) (vla-get-objectid32 object))
(defun _GetObjectID ( object ) (vla-get-objectid object))
)
(_GetObjectID object)
)
tl;dr: Test once, and only as much as is req'd.
-
If one prefers the obfuscated:
(defun _GetObjectID ( object )
(eval
(cons 'defun
(cons '_GetObjectID
(list '(object)
(list
(if vla-get-objectid32 'vla-get-objectid32 'vla-get-objectid)
'object
)
)
)
)
)
(_GetObjectID object)
)
-
If one prefers the obfuscated:
< .. >
I'm sure there is one.
-
lolz
-
The "obfuscated" version worked great in 2012. Since I don't have 2015, and I'm helping someone who does, I'll get back with you on if it works there. Many thanks.
-
You're welcome and thanks for letting me know -- I wrote it under 2010 -- conceptually it should work for 2015 -- but it's merely a guess.
-
An aside -- is Rabbit the same person that used to post in the Take 5 forum with David Doane and crew a million years ago?
-
Another variant for fun (penned under 2011, appears to work fine):
(defun _GetObjectID ( object )
(eval
(list 'defun '_GetObjectID '(object)
(list
(if vla-get-objectid32 'vla-get-objectid32 'vla-get-objectid)
'object
)
)
)
(_GetObjectID object)
)
-
An aside -- is Rabbit the same person that used to post in the Take 5 forum with David Doane and crew a million years ago?
Yes, and both are still posting. You should stop by and say "hello".
-
Wow. Didn't know it was still active. Can you pm me the link Owen? Thanks so much for letting me know. tl;dr: I feelz old now.
-
FWIW .. Michael's version breaks Lee's code in AutoCAD 2015 x64. Don't have an x86 computer to test on.
(setq o (vlax-ename->vla-object (car (entsel))))
#<VLA-OBJECT IAcadLWPolyline 000000f2812dbb28>
MP_GETOBJECTID
1055
RJP_GETOBJECTID
"140694991308416"
Apparently vla-setblocktablerecordid will accept an integer or string.
-
Damn. I have to get AutoCAD 2015 installed. :police:
Thanks for letting me know Ron.
-
Glad to help 8)
-
Regardless that vla-setblocktablerecordid will accept a string ... given that vla-get-objectid returns an int aren't you tempted to return same from your alt?
-
Regardless that vla-setblocktablerecordid will accept a string ... given that vla-get-objectid returns an int aren't you tempted to return same from your alt?
That would probably be a good idea.
Would you know why (atoi "140694991308416") returns 2147483647 ?
-
^
http://docs.autodesk.com/ACD/2013/ENU/index.html?url=files/GUID-EF6114FC-F1E4-4C71-91CC-07D01E6C8ABB.htm,topicNumber=d30e573784
-
Would you know why (atoi "140694991308416") returns 2147483647 ?
Probably, because there are 16^8 integers...
Command: (fix (atof (rtos (/ (- (expt 16. 8) 1) 2))))
2147483647
-
I'm not at my computer (road trip ftw) but my inclination would be to use read, anyone try that?
-
Read does not work either.
-
How about distof?
-
Distof returns the same value as read :(
-
Thanks for trying Ron.
-
As discussed previously (http://www.theswamp.org/index.php?topic=37312.msg423177#msg423177), I believe the atoi method won't work as the integer conversion functions in AutoLISP are only compatible with 32-bit signed integers and the 64-bit method requires a Long rather than an Int.
This link seems to describe the changes made to the ActiveX API in 2015:
http://help.autodesk.com/view/ACD/2015/ENU/?guid=GUID-6FEDBCCA-91D0-4782-AE5A-49BD4384FD8C
Though, its odd that the setblocktablerecordid method now accepts either a 32-bit integer or a string for 64-bit systems - certainly, this behaviour is not detailed in the documentation (http://help.autodesk.com/view/ACD/2015/ENU/?guid=GUID-8A78F69E-EACF-4985-B9E1-6DA662240AF0).
With these changes in mind, and to retain compatibility with earlier 64-bit systems, I would suggest perhaps:
(defun LM:objectid ( obj )
(eval
(list 'defun 'LM:objectid '( obj )
(cond
( (not (wcmatch (getenv "PROCESSOR_ARCHITECTURE") "*64*"))
'(vla-get-objectid obj)
)
( (= 'subr (type vla-get-objectid32))
'(vla-get-objectid32 obj)
)
( (list 'vla-getobjectidstring (vla-get-utility (LM:acdoc)) 'obj ':vlax-false))
)
)
)
(LM:objectid obj)
)
(defun LM:acdoc nil
(eval (list 'defun 'LM:acdoc 'nil (vla-get-activedocument (vlax-get-acad-object))))
(LM:acdoc)
)
But unfortunately I don't have access to a 64-bit system for testing. :(
-
Nice solution , Lee :-)
In my case : In Acad2011 64bit system , Object has two property about ID <ObjectID32> <ObjectID>
In Acad2015 64bit system , Object has only one ID <ObjectID>
(vl-load-com)
(defun _ObjectID (OBJ / ID)
(vl-catch-all-apply
(function
(lambda nil
(setq ID
(vlax-get
obj
(quote objectid)))))) id)
;;For test
(_ObjectID (vlax-ename->vla-object (car (entsel))))
-
Nice solution , Lee :-)
Thanks chlh_jd :-)
In my case : In Acad2011 64bit system , Object has two property about ID <ObjectID32> <ObjectID>
In Acad2015 64bit system , Object has only one ID <ObjectID>
If I've understood the API change correctly, the objectid property in 64-bit versions < 2015 (maybe 2014 also?) will return an incorrect object ID, and the objectid32 property must be used instead for these systems.
Could anyone confirm whether the value returned by the objectid property in 64-bit 2015 can be used with the setblocktablerecordid method?
-
If I've understood the API change correctly, the objectid property in 64-bit versions < 2015 (maybe 2014 also?) will return an incorrect object ID, and the objectid32 property must be used instead for these systems.
Could anyone confirm whether the value returned by the objectid property in 64-bit 2015 can be used with the setblocktablerecordid method?
I has catch this case sometime in AutoCAD2011 , but didn't know when it come in correct , perhaps I'v update it or .Net Frame .
-
Nice solution , Lee :)
Thanks chlh_jd :)
....
Could anyone confirm whether the value returned by the objectid property in 64-bit 2015 can be used with the setblocktablerecordid method?
Lee,
From my tests, you can feed setblocktablerecordid the INT value generated from (vla-get-objectid obj) but it does not generate the block preview in the table. The STRING value returned from (vlax-invoke-method (vla-get-utility doc) 'getobjectidstring obj :vlax-false) works ... strange. :o
-
From my tests, you can feed setblocktablerecordid the INT value generated from (vla-get-objectid obj) but it does not generate the block preview in the table. The STRING value returned from (vlax-invoke-method (vla-get-utility doc) 'getobjectidstring obj :vlax-false) works ... strange. :o
Cheers Ron - strange indeed. :|
-
Thank you all for your respective work and the resulting informative thread, good read.
An aside and for the curious, the value returned by GetObjectIDString is not the same as the ObjectID but it is the same as an entity's ename converted from hex to decimal. Sorry if this is mentioned elsewhere -- if it was I've not seen it so I thought I'd mention it.