MartinSomerville Posted July 16, 2009 Posted July 16, 2009 Hello again. We are looking into xdata at the moment with autolisp. Can write and read but i can't figure out how to change. I've tried subst with the -3 sublist. It all looks good but doesn't update the entity (ie it still reads the same as the old). Also have tried appending the new -3 sublist. That didn't work. Can someone tell this is possible and how to go about it. Thanks Martin Quote
MartinSomerville Posted July 16, 2009 Author Posted July 16, 2009 I get these errors with the subst method i tried: ; error: bad argument type: consp nil ; error: Exception occurred: 0xC0000005 (Access Violation) ; warning: unwind skipped on exception ; error: Exception occurred: 0xC0000005 (Access Violation) Quote
flowerrobot Posted July 16, 2009 Posted July 16, 2009 From what i understand, sounds like your doing it right, only thing is are you using entmod? Would make things easyer if you posted your code Quote
MartinSomerville Posted July 16, 2009 Author Posted July 16, 2009 thanks fr. Yeah, I just thought I'd see if doing it ok. Yeah was using entmod, like the way the xdata was created. It's a 3D ent so a lot of the time the whole entity doesn't show on the textscr, which makes it hard for me to see what is going on at the end sometimes. Can I change this somehow. I'll try and get something together and post soon. Thanks again Martin Quote
Lee Mac Posted July 16, 2009 Posted July 16, 2009 Could you not approach it using a VL method? For example: (defun putxdat (Obj App Data / ent type1 valeur) (setq xtype (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbInteger '(0 . 1)) '(1001 1000)))) (setq xval (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbVariant '(0 . 1)) (list App Data)))) (vla-setXData Obj xtype xval)) I used the above to put an object's handle into the xdata. Quote
MartinSomerville Posted July 17, 2009 Author Posted July 17, 2009 thanks lee. I'll check that out but will try and figure in autolisp first. I think it may have something to do with entmodding an entity with a reactor I applied ?? code to write xdata initially: (defun write-xdata (xdata-type1 xdata-type2 xdata-data / xdata-for-mod xdata-to-add xdata-to-add-list new-xdata data-list) (regapp "XXXX") (setq xdata-for-mod (entget (entlast) '("XXXX"))) (cond ( (= e0-cdr "LINE") (setq e10-cdr (cdr (assoc 10 (entget ename))) e11-cdr (cdr (assoc 11 (entget ename))) dist (distance e11-cdr e10-cdr) data-list (list "XXXX" (cons 1000 xdata-type1) (cons 1000 xdata-type2) (cons 1000 xdata-data) (cons 1000 (rtos dist 2 3)) (cons 1011 (cdr (assoc 10 (entget ename)))) (cons 1011 (cdr (assoc 11 (entget ename)))) ;(cons 1041 (distance e10-cdr e11-cdr)) ) ) ) ( t (setq data-list (list "XXXX" (cons 1000 xdata-type1) (cons 1000 xdata-type2) (cons 1000 xdata-data) ;(cons 1011 e10-cdr) ;(cons 1011 e11-cdr) ;(cons 1041 (distance e10-cdr e11-cdr)) ) ) ) ) (setq xdata-to-add (list -3 data-list)) (setq xdata-to-add-list (list xdata-to-add)) (setq new-xdata (append xdata-for-mod xdata-to-add-list)) (entmod new-xdata) (create-vlisp-objects) (setq o-e (vlax-ename->vla-object (entlast))) (setq object-reactor (vlr-object-reactor (list o-e) "3DTubeReactor" '((:vlr-modified . update-length)))) ) to write over with modify reactor: (messy I know) (defun update-length (notifier-object reactor-object parameter-list) ; not used as reactor above is commented out (alert "trying to update length in xdata. check it") (setq a notifier-object) (setq b reactor-object) (setq c parameter-list) (setq ul-ename (vlax-vla-object->ename notifier-object)) (setq ul-eget (entget ul-ename '("XXXX"))) (setq ul-e-3 (assoc -3 ul-eget)) (setq ul-e-3-cdr (cdr ul-e-3)) (setq ul-e-3-cdr-car (car ul-e-3-cdr)) (setq w-list (cdr ul-e-3-cdr-car)) (setq pt-A (cdr (nth 4 w-list))) (setq pt-B (cdr (nth 5 w-list))) (setq new-d (distance pt-A pt-B)) ;;;setting up new -3 data (setq new-list (list "XXXX")) (setq count 0) (repeat (length w-list) (setq ul-nth (nth count w-list)) (if (/= count 3) (setq new-list (append new-list (list ul-nth))) (setq new-list (append new-list (list (cons 1000 (rtos new-d 2 3))))) ) (setq count (1+ count)) ) (setq new-ul-e-3 (list -3 new-list)) (setq new-ul-eget (subst new-ul-e-3 ul-e-3 ul-eget)) ; trying subst method (entmod new-ul-eget) el-eget: ((-1 . <Entity name: 7ef06378>) (0 . "3DSOLID") (330 . <Entity name: 7ef01cb8>) (5 . "252F") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (100 . "AcDbModelerGeometry") (70 . 1) (1 . "mnmoo mg m mi ") (1 . "ni ^*+0;:,4 ^*+0\\^[ nh ^LR nmqoqnqfnj QK o ") (1 . "n fqfffffffffffffffj:rooh n:rono ") (1 . ">,27:>;:- {rn rn _nn mnmqoqnqfnj |") (1 . "=0;& {rn rn {rn {m {rn {rn |") (1 . "3*2/ {rn rn {rn {rn {l {n |") (1 . ",7:33 {rn rn {rn {rn {rn {k {rn {m |") (1 . "9><: {rn rn {rn {j {i {l {rn {h 90-(>-; ,6183: |") (1 . "9><: {g rn {rn {f {no {l {rn {nn -:-,:; ,6183: |") (1 . "300/ {rn rn {rn {nm {nl {k |") (1 . "<01:r,*-9><: {rn rn {rn roqfkfmjofhjnlmjjmgj oqhojkffiohljfhiijg o o roqmkfklimggknhfmokg oqfiglfnmnnmkifmhgk nliqjjooooooooooon o o n V V o n nliqjjooooooooooon 90-(>-; V V V V |") (1 . "1>2:@>++-6=r8:1r>++-6= {rn rn {rn {rn {j 30,: 30,: >//3& <0/& _ni ,(::/@,+>-+@9><: |") (1 . "9><: {nk rn {rn {rn {nj {l {rn {ni 90-(>-; ,6183: |") (1 . "300/ {rn rn {rn {rn {nh {j |") (1 . "/3>1:r,*-9><: {rn rn {rn roqfkfmjofhjnlmjjmgj oqhojkffiohljfhiijg o o roqmkfklimggknhfmokl oqfiglfnmnnmkifmhgk n o ro 90-(>-;@) V V V V |") (1 . "300/ {rn rn {rn {rn {ng {k |") (1 . "<0:;8: {rn rn {rn {nl {nl {nf {mo 90-(>-; {i {rn |") (1 . "1>2:@>++-6=r8:1r>++-6= {rn rn {rn {rn {f 30,: 30,: >//3& <0/& _nk ,(::/@:1;@9><: |") (1 . "300/ {rn rn {rn {rn {nf {f |") (1 . "/3>1:r,*-9><: {rn rn {rn roqfkfmjofhjnlmjjmgj rnokoqnmlnmhkilmljl kokoqgmgimhohojfkg o roqmkfklimggknhfmokl oqfiglfnmnnmkifmhgk n o o 90-(>-;@) V V V V |") (1 . "<0:;8: {rn rn {rn {nh {nh {ng {mn -:-,:; {no {rn |") (1 . "<0:;8: {rn rn {rn {ng {ng {nh {mn 90-(>-; {nm {rn |") (1 . "<0:;8: {rn rn {rn {nf {nf {nl {mo -:-,:; {nj {rn |") (1 . ":;8: {rn rn {rn {mm rgqloigglmfljngfjnj:roni {mm iqmglngjlohnhfjgjl {nl {ml 90-(>-; _h *1410(1 |") (1 . ":;8: {rn rn {rn {mk o {mk iqmglngjlohnhfjgim {ng {mj 90-(>-; _h *1410(1 |") (1 . "):-+:' {rn rn {rn {mo m {mi |") (1 . ":336/,:r<*-): {rn rn {rn roqfkfmjofhjnlmjjmgj rnokoqnmlnmhkilmljl kokoqgmgimhohojfkg o oqmkfklimggknhfmokl roqfiglfnmnnmkifmhgk nliqjjooooooooooon o o n V V |") (1 . "):-+:' {rn rn {rn {mn m {mh |") (1 . ":336/,:r<*-): {rn rn {rn roqfkfmjofhjnlmjjmgj oqhojkffiohljfhiijg o o roqmkfklimggknhfmokl oqfiglfnmnnmkifmhgk nliqjjooooooooooon o o n V V |") (1 . "/061+ {rn rn {rn nljqioohkfomkgihkh rnokoqnmlnmhkilmljl kokoqgmgimhohojfjl |") (1 . "/061+ {rn rn {rn nljqioohkfomkgihkh oqhojkffiohljfhiijg o |") (100 . "AcDb3dSolid") (350 . <Entity name: 7ef06390>) (-3 ("XXXX" (1000 . "TUBEMEMBER") (1000 . "CHS") (1000 . "273.1x8.2") (1000 . "3000") (1011 -0.949251 0.7055 0.0) (1011 -0.949251 -1040.12 4040.83)))) ul-e-3: (-3 ("XXXX" (1000 . "TUBEMEMBER") (1000 . "CHS") (1000 . "273.1x8.2") (1000 . "3000") (1011 -0.949251 0.7055 0.0) (1011 -0.949251 -1040.12 4040.83))) new-ul-e-3: (-3 ("XXXX" (1000 . "TUBEMEMBER") (1000 . "CHS") (1000 . "273.1x8.2") (1000 . "4172.723") (1011 -0.949251 0.7055 0.0) (1011 -0.949251 -1040.12 4040.83))) new-ul-eget ((-1 . <Entity name: 7ef06378>) (0 . "3DSOLID") (330 . <Entity name: 7ef01cb8>) (5 . "252F") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (100 . "AcDbModelerGeometry") (70 . 1) (1 . "mnmoo mg m mi ") (1 . "ni ^*+0;:,4 ^*+0\\^[ nh ^LR nmqoqnqfnj QK o ") (1 . "n fqfffffffffffffffj:rooh n:rono ") (1 . ">,27:>;:- {rn rn _nn mnmqoqnqfnj |") (1 . "=0;& {rn rn {rn {m {rn {rn |") (1 . "3*2/ {rn rn {rn {rn {l {n |") (1 . ",7:33 {rn rn {rn {rn {rn {k {rn {m |") (1 . "9><: {rn rn {rn {j {i {l {rn {h 90-(>-; ,6183: |") (1 . "9><: {g rn {rn {f {no {l {rn {nn -:-,:; ,6183: |") (1 . "300/ {rn rn {rn {nm {nl {k |") (1 . "<01:r,*-9><: {rn rn {rn roqfkfmjofhjnlmjjmgj oqhojkffiohljfhiijg o o roqmkfklimggknhfmokg oqfiglfnmnnmkifmhgk nliqjjooooooooooon o o n V V o n nliqjjooooooooooon 90-(>-; V V V V |") (1 . "1>2:@>++-6=r8:1r>++-6= {rn rn {rn {rn {j 30,: 30,: >//3& <0/& _ni ,(::/@,+>-+@9><: |") (1 . "9><: {nk rn {rn {rn {nj {l {rn {ni 90-(>-; ,6183: |") (1 . "300/ {rn rn {rn {rn {nh {j |") (1 . "/3>1:r,*-9><: {rn rn {rn roqfkfmjofhjnlmjjmgj oqhojkffiohljfhiijg o o roqmkfklimggknhfmokl oqfiglfnmnnmkifmhgk n o ro 90-(>-;@) V V V V |") (1 . "300/ {rn rn {rn {rn {ng {k |") (1 . "<0:;8: {rn rn {rn {nl {nl {nf {mo 90-(>-; {i {rn |") (1 . "1>2:@>++-6=r8:1r>++-6= {rn rn {rn {rn {f 30,: 30,: >//3& <0/& _nk ,(::/@:1;@9><: |") (1 . "300/ {rn rn {rn {rn {nf {f |") (1 . "/3>1:r,*-9><: {rn rn {rn roqfkfmjofhjnlmjjmgj rnokoqnmlnmhkilmljl kokoqgmgimhohojfkg o roqmkfklimggknhfmokl oqfiglfnmnnmkifmhgk n o o 90-(>-;@) V V V V |") (1 . "<0:;8: {rn rn {rn {nh {nh {ng {mn -:-,:; {no {rn |") (1 . "<0:;8: {rn rn {rn {ng {ng {nh {mn 90-(>-; {nm {rn |") (1 . "<0:;8: {rn rn {rn {nf {nf {nl {mo -:-,:; {nj {rn |") (1 . ":;8: {rn rn {rn {mm rgqloigglmfljngfjnj:roni {mm iqmglngjlohnhfjgjl {nl {ml 90-(>-; _h *1410(1 |") (1 . ":;8: {rn rn {rn {mk o {mk iqmglngjlohnhfjgim {ng {mj 90-(>-; _h *1410(1 |") (1 . "):-+:' {rn rn {rn {mo m {mi |") (1 . ":336/,:r<*-): {rn rn {rn roqfkfmjofhjnlmjjmgj rnokoqnmlnmhkilmljl kokoqgmgimhohojfkg o oqmkfklimggknhfmokl roqfiglfnmnnmkifmhgk nliqjjooooooooooon o o n V V |") (1 . "):-+:' {rn rn {rn {mn m {mh |") (1 . ":336/,:r<*-): {rn rn {rn roqfkfmjofhjnlmjjmgj oqhojkffiohljfhiijg o o roqmkfklimggknhfmokl oqfiglfnmnnmkifmhgk nliqjjooooooooooon o o n V V |") (1 . "/061+ {rn rn {rn nljqioohkfomkgihkh rnokoqnmlnmhkilmljl kokoqgmgimhohojfjl |") (1 . "/061+ {rn rn {rn nljqioohkfomkgihkh oqhojkffiohljfhiijg o |") (100 . "AcDb3dSolid") (350 . <Entity name: 7ef06390>) (-3 ("XXXX" (1000 . "TUBEMEMBER") (1000 . "CHS") (1000 . "273.1x8.2") (1000 . "4172.723") (1011 -0.949251 0.7055 0.0) (1011 -0.949251 -1040.12 4040.83)))) lot of data here. Thanks for anyone willing to try and look at. Regards, Martin Quote
MartinSomerville Posted July 17, 2009 Author Posted July 17, 2009 yeah it was the reactor. I guess the entmod is triggering the reactor and creating a loop. I guess I now have to deactivate the reactor to entmod and then add the reactor back afterwards? I think I need to think more about it. Probably a better was to achieve what trying to do. (which is basicallya reading in the 2 xdata end points 1011 (which move with the 3d pipe) and adding the new length back into the xdata. was hoping to add other things aswell as this was just the start. thanks Quote
MartinSomerville Posted July 17, 2009 Author Posted July 17, 2009 ha. I'm a bit stuck. Prob cos my brain ain't working. I think I need to learn more about visualLisp and reactors. This is what I am trying to do: xdata attached to cylinder. - end points and length. Done. this object is the owner of a reactor object - modify when complete say (:vlr-objectClosed) this calls a function that reads the end pt xdata and updates the new length xdata in the object (calculated from the new end points). I am having trouble as I thought I could remove the object reactor in the call back function but don't think I can. ah it's time for home. I think it's possible I just have to figure it out Quote
Lee Mac Posted July 17, 2009 Posted July 17, 2009 I had some trouble with Object Reactors - they seem to fire continuously when modifying an object. In the end, I resorted to using a command reactor, and had it react from grip modifications. Not ideal, but it worked... http://www.cadtutor.net/forum/showthread.php?t=37639 Quote
MartinSomerville Posted July 19, 2009 Author Posted July 19, 2009 Thanks Lee. Well if you had trouble, I'm screwed. Will check out the link martin Quote
Lee Mac Posted July 19, 2009 Posted July 19, 2009 Well, maybe you might have some luck, you never know Another discussion on the same topic here: http://www.theswamp.org/index.php?topic=29381.0 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.