Jump to content

Recommended Posts

Posted

I want to change the line type of the last entity drawn (an arc) from continuous to dashed. What is failing?:oops:

 

...
(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)

Posted

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]

Posted

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"))))
)

Posted

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.

Posted

It wont do you no good if the Dashed Linetype is not loaded in the drawing.. ( I think)

Posted

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")
)

Posted
Good observation, pBe!

 

Its nothing really, sometimes we fail to notice the obvious and the small things (only human)

 

Cheers Mirea :thumbsup:

Posted

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.

Posted

Other two solutions for linetype change:

(vla-put-LineType (vlax-ename->vla-object (entlast)) "DASHED")

and

(command "_CHPROP" (entlast) "" "_LT" "DASHED" "")

Posted
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.

Posted
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]))

Posted

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)
)

Posted
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. ;)

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...