teknomatika Posted April 10, 2012 Posted April 10, 2012 I want to change the line type of the last entity drawn (an arc) from continuous to dashed. What is failing? ... (command "_.arc" "c" "_non" pt1 "_non" pt3 "_non" pt2 "") (setq ent1 (entlast)) (setq ent2 (entget ent1)) (setq ent2 (subst (cons 6 "dashed") (assoc 6 entdados) ent2 )) (entmod ent2) Quote
MSasu Posted April 10, 2012 Posted April 10, 2012 If the linetype is associated by layer, then the DXF code 6 is not available; so you code should become: [color=red](if (assoc 6 ent2)[/color] (setq ent2 (subst (cons 6 "DASHED") (assoc 6 [color=red]ent2[/color]) ent2)) [color=#ff0000](setq ent2 (append ent2 (list (cons 6 "DASHED"))))[/color] [color=red])[/color] [color=black](entmod ent2)[/color] Quote
teknomatika Posted April 10, 2012 Author Posted April 10, 2012 Mircea, I appreciate the help. However, correct, but does not seem to update. Probably, I went back to doing something wrong. ...(command "_.arc" "c" "_non" pt1 "_non" pt3 "_non" pt2 "") (setq ent1 (entlast)) (setq ent2 (entget ent1)) (if (assoc 6 ent2) (entmod (subst (cons 6 "DASHED") (assoc 6 ent2) ent2)) (entmod (append ent2 (list (cons 6 "DASHED")))) ) Quote
MSasu Posted April 10, 2012 Posted April 10, 2012 Did you checked to have an appropriate value for LTSCALE system variable? To validate the linetype of the entity you should either select it in drawing and check the properties or print his associated list. Quote
pBe Posted April 10, 2012 Posted April 10, 2012 It wont do you no good if the Dashed Linetype is not loaded in the drawing.. ( I think) Quote
MSasu Posted April 10, 2012 Posted April 10, 2012 To ensure that the required linetype is availabe in current drawing: (if (not (tblsearch "LTYPE" "DASHED")) (vla-load (vla-get-Linetypes (vla-get-ActiveDocument (vlax-get-acad-object))) "DASHED" "ACAD.LIN") ) Quote
pBe Posted April 10, 2012 Posted April 10, 2012 Good observation, pBe! Its nothing really, sometimes we fail to notice the obvious and the small things (only human) Cheers Mirea Quote
teknomatika Posted April 10, 2012 Author Posted April 10, 2012 They are right. Indeed, preloading the line type, the update is assured. Thank you for your lesson. Updated... ...(command "_.arc" "c" "_non" pt1 "_non" pt3 "_non" pt2 "") (if (not (tblsearch "LTYPE" "DASHED")) (vla-load (vla-get-Linetypes (vla-get-ActiveDocument (vlax-get-acad-object))) "DASHED" "ACAD.LIN") ) (setq ent1 (entlast)) (setq ent2 (entget ent1)) (if (assoc 6 ent2) (entmod (subst (cons 6 "DASHED") (assoc 6 ent2) ent2)) (entmod (append ent2 (list (cons 6 "DASHED")))) ) By the way, getting my exercise in, that code would i need to change not only the last entity of the design but also the penultimate? In this case, a line. Quote
MSasu Posted April 10, 2012 Posted April 10, 2012 Other two solutions for linetype change: (vla-put-LineType (vlax-ename->vla-object (entlast)) "DASHED") and (command "_CHPROP" (entlast) "" "_LT" "DASHED" "") Quote
MSasu Posted April 10, 2012 Posted April 10, 2012 By the way, getting my exercise in, that code would i need to change not only the last entity of the design but also the penultimate? In this case, a line. For this you should look to ENTNEXT function. Quote
irneb Posted April 10, 2012 Posted April 10, 2012 To ensure that the required linetype is availabe in current drawing: (if (not (tblsearch "LTYPE" "DASHED")) (vla-load (vla-get-Linetypes (vla-get-ActiveDocument (vlax-get-acad-object))) "DASHED" [color=red]"ACAD.LIN"[/color]) ) Just one small thing for those not working in Imperial units:(if (not (tblsearch "LTYPE" "DASHED")) (vla-load (vla-get-Linetypes (vla-get-ActiveDocument (vlax-get-acad-object))) "DASHED" [color=red](cond ((= (getvar "Measurement") 0) "ACAD.LIN") ("ACADISO.LIN"))[/color])) Quote
godofcad Posted April 10, 2012 Posted April 10, 2012 Try this codes buddy ....... (defun c:dash (/ s) (setvar "cmdecho" 0) (if (setq s (ssget '((0 . "LINE,POLYLINE,LWPOLYLINE")))) (progn [color="blue"](command "chprop" s "" "lt" "DASHED" "")[/color] ) (Princ "\nNothing Selected:") ) (princ) ) Quote
Tharwat Posted April 10, 2012 Posted April 10, 2012 Try this codes buddy ....... (defun c:dash (/ s) (setvar "cmdecho" 0) (if (setq s (ssget '((0 . "LINE,POLYLINE,LWPOLYLINE")))) (progn [color="blue"](command "chprop" s "" "lt" "DASHED" "")[/color] ) (Princ "\nNothing Selected:") ) (princ) ) This code will never return the system variable cmdecho back as it was before buddy. 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.