guitarguy1685 Posted February 1, 2010 Posted February 1, 2010 hello again, I'm am continuing my experimentation with DXF codes. I'm want to write a lisp that will change the color and linetype of an object to color 9 and hidden2. If the color and linetype are NOT bylayer my code works since the DXF codes for them exists. 62 = color and 6=Ltype. I basically just change what is currently there. However if they are set to Bylayer then the DXF codes do not exist and my codes fail since I can't change what doesn't exist. I need to actually add the codes. I tried one way w/ append but it didn't work. Let me show you what I have so far. (defun C:MakeHidden () (setq ObjHid (car (entsel "\nSelect object to make hidden"))) (setq ObjLst (entget Objhid)) (entmod (subst (cons 62 9)(assoc 62 ObjLst) ObjLst)) (entmod (subst (cons 6 "Hidden2")(assoc 6 ObjLst) ObjLst)) (entupd ObjHid)) I tried this to add the codes (append '(62 9) ObjLst) but that was a failure. Quote
Lee Mac Posted February 1, 2010 Posted February 1, 2010 Read this: http://www.cadtutor.net/forum/showthread.php?t=44216 Quote
lpseifert Posted February 1, 2010 Posted February 1, 2010 Here's an alternate way- it doesn't matter if the original is Bylayer (vlax-load-com);load com (setq obj (vlax-ename->vla-object (car (entsel))));select an entity and turn it into an object (vlax-put-property obj 'Color 9);change the object's color to 9 (vlax-put-property obj 'Linetype "hidden2");change the object's linetype to hidden2 Quote
Lee Mac Posted February 1, 2010 Posted February 1, 2010 Here's an alternate way- it doesn't matter if the original is Bylayer (vlax-load-com);load com (setq obj (vlax-ename->vla-object (car (entsel))));select an entity and turn it into an object (vlax-put-property obj 'Color 9);change the object's color to 9 (vlax-put-property obj 'Linetype "hidden2");change the object's linetype to hidden2 You're getting pretty hooked on this VL stuff... Quote
lpseifert Posted February 1, 2010 Posted February 1, 2010 You're getting pretty hooked on this VL stuff... I find it's much simpler for situations like this... but it can be a bear for others. I wish I knew more about the vla- functions. Vlide helps, but if you don't know what you're looking for it's kinda hard to leaf through to find a method... Quote
Lee Mac Posted February 1, 2010 Posted February 1, 2010 I find it's much simpler for situations like this... but it can be a bear for others. I wish I knew more about the vla- functions. Vlide helps, but if you don't know what you're looking for it's kinda hard to leaf through to find a method... True, sometimes you just have to try to put 2+2 together Quote
guitarguy1685 Posted February 1, 2010 Author Posted February 1, 2010 I find it's much simpler for situations like this... but it can be a bear for others. I wish I knew more about the vla- functions. Vlide helps, but if you don't know what you're looking for it's kinda hard to leaf through to find a method... yeah i'd like to learn more about the vl- functions but I don't know where to start. I just kind of pick stuff up here and there. I'm going to use the ones you mentioned. thanks alot. Quote
Lee Mac Posted February 1, 2010 Posted February 1, 2010 yeah i'd like to learn more about the vl- functions but I don't know where to start. I just kind of pick stuff up here and there. I'm going to use the ones you mentioned. thanks alot. There is a lot of info in the Visual LISP Help files, but most are written for VBA, so you have to make a connection. Quote
guitarguy1685 Posted February 2, 2010 Author Posted February 2, 2010 Here's an alternate way- it doesn't matter if the original is Bylayer (vlax-load-com);load com (setq obj (vlax-ename->vla-object (car (entsel))));select an entity and turn it into an object (vlax-put-property obj 'Color 9);change the object's color to 9 (vlax-put-property obj 'Linetype "hidden2");change the object's linetype to hidden2 I tried your code and I got this error at first ; error: no function definition: VLAX-LOAD-COM I removed it and now it seems to work fine 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.