BLOACH85 Posted March 3, 2009 Posted March 3, 2009 I have a routine that offsets on both sides that i have written but i want the line entity (original object) to change to a "cyan" color # 4 and the two outside lines to be a "yellow" #2 color. Does anyone know the correct syntax and variables to be used? Quote
BLOACH85 Posted March 3, 2009 Author Posted March 3, 2009 A man with little words Gets alot Done! Quote
BLOACH85 Posted March 3, 2009 Author Posted March 3, 2009 Ok so ive tried it and im still pulling a syntax error here is the code the color and defualt values are all thats left that need to be fixed Quote
BLOACH85 Posted March 3, 2009 Author Posted March 3, 2009 (defun c:bs (/ os cmd entity dist object keywrd) (setq os (getvar "osmode")) (setq cmd (getvar "cmdecho")) (setvar "osmode" 0) (setvar "cmdecho" 0) (while (not entity) (if (eq (setq entity (car (entsel "\nSelect line to offset: "))) nil) (princ "\nThat was not a line. Please select a line!: "))) (initget (+ 1 2 4 64)) (setq dist (getdist "\nEnter offset distance: [0.83/0.95] <0.83> ")) (initget (+ 2 4) "Yes No") (setq keywrd (getkword "\nDelete original object [Yes/No] <No>: ")) (if (/= keywrd "Yes") (setq keywrd "No")) (setq object (vlax-ename->vla-object entity) ) (vla-offset object dist) (vla-offset object (* dist -1) ) (if (eq keywrd "Yes") (vla-erase object) ) (setvar "osmode" os) (setvar "cmdecho" cmd) (princ) ) Quote
ASMI Posted March 3, 2009 Posted March 3, 2009 (defun c:bs (/ os cmd entity dist object nObj keywrd) (vl-load-com) (setq os (getvar "osmode")) (setq cmd (getvar "cmdecho")) (setvar "osmode" 0) (setvar "cmdecho" 0) (while (not entity) (if (eq (setq entity (car (entsel "\nSelect line to offset: "))) nil) (princ "\nThat was not a line. Please select a line!: "))) (initget (+ 1 2 4 64)) (setq dist (getdist "\nEnter offset distance: [0.83/0.95] <0.83> ")) (initget (+ 2 4) "Yes No") (setq keywrd (getkword "\nDelete original object [Yes/No] <No>: ")) (if (/= keywrd "Yes") (setq keywrd "No")) (setq object (vlax-ename->vla-object entity)) [color="Blue"](vla-put-Color object 4) (setq nObj(car(vlax-safearray->list(vlax-variant-value(vla-offset object dist))))) (vla-put-Color nObj 2) (setq nObj(car(vlax-safearray->list(vlax-variant-value(vla-offset object(- dist)))))) (vla-put-Color nObj 2)[/color] (if (eq keywrd "Yes") (vla-erase object) ) (setvar "osmode" os) (setvar "cmdecho" cmd) (princ) ) Offset method returns variant - array of the new objects. Quote
BLOACH85 Posted March 3, 2009 Author Posted March 3, 2009 ASMI, You are the man now what i think that im beginning to understand what you did but thats about three more lines then what i had. If you dont mind could you explain a little? Quote
ASMI Posted March 3, 2009 Posted March 3, 2009 If you dont mind could you explain a little? Ok. We will use command line. Draw a line. Pick it and transform to vla-object at once: Command: (setq vline(vlax-ename->vla-object(car(entsel)))) Select object: #<VLA-OBJECT IAcadLine 0116a5f4> Now apply offset method and save result into variable: Command: (setq vrnt(vla-Offset vline 10.0)) #<variant 8201 ...> Now you have Variant - data type which can contain any data. Look how data inside variant: Command: (setq arr(vlax-variant-value vrnt)) #<safearray...> It is safearray - matrix with data. Transform it to a list: Command: (setq lst(vlax-safearray->list arr)) (#<VLA-OBJECT IAcadLine 0116a924>) Ok it list with a new line. Extract it with car function and paint to the red: Command: (vla-put-Color (car lst) 1) nil All done... Look for variants and arrays inside ActiveX functions here. Quote
BLOACH85 Posted March 3, 2009 Author Posted March 3, 2009 Yea, Thanks for that ASMI i got it now. 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.