Change linetype

Change linetype

Anonymous
Not applicable
1,923 Views
4 Replies
Message 1 of 5

Change linetype

Anonymous
Not applicable

Hey, I'm trying to change the linetype of a polyline from Bylayer to continous. Heres the code I have so far, not really sure where I am going wrong. No errors were thrown from my end. 

 

(setq ent(entget(car(entsel))))
(setq entChange(subst (cons 6 "continous") (assoc 6 ent) ent ))
(entmod entChange)

0 Likes
Accepted solutions (1)
1,924 Views
4 Replies
Replies (4)
Message 2 of 5

doaiena
Collaborator
Collaborator
Accepted solution

How about this:

(setq ent (car (entsel)))
(vla-put-Linetype (vlax-ename->vla-object ent) "Continuous")

0 Likes
Message 3 of 5

Kent1Cooper
Consultant
Consultant

Continuous has an additional "u" in it.

 

That change alone was enough [for me] in a quick test.  But you can also do without the middle-man variable:

(setq ent (entget (car (entsel))))
(entmod (subst (cons 6 "continuous") (assoc 6 ent) ent))

 

And if you're going to use one of the (vla-put...) suggestions, you could need to add

  (vl-load-com)

somewhere if it might not always have been loaded.

 

Further EDIT:

It occurred to me that I had tried it on something with a linetype override, and that if something doesn't have that, there will be no (assoc 6 ent) to replace!  Sure enough, trying it on something of ByLayer linetype, it didn't work.  But if an entity data list has more than one entry of the same association number, the last one wins.  That means you can (append) one onto the end, and if there's one earlier, it will be overridden, and if there isn't one earlier, the new one will take effect.  [Also, with a specific value, you can make the association entry directly, without using (cons).]

 

This works whether something is initially of ByLayer or some overridden linetype:

(setq ent (entget (car (entsel))))
(entmod (append ent '((6 . "Continuous"))))

Kent Cooper, AIA
Message 4 of 5

rkmcswain
Mentor
Mentor

Here is one way.

 

(setq ent (car (entsel)))
(setq obj (vlax-ename->vla-object ent))
(vla-put-Linetype obj "Continuous")

You spelled continuous wrong in yours also.

R.K. McSwain     | CADpanacea | on twitter
Message 5 of 5

Sea-Haven
Mentor
Mentor

My $0.05 non variable version

 

(vla-put-Linetype  (vlax-ename->vla-object (car (entsel))) "Continuous")

0 Likes