Problems Changing Linetype Scale to Existing Line

Problems Changing Linetype Scale to Existing Line

mgorecki
Collaborator Collaborator
1,018 Views
6 Replies
Message 1 of 7

Problems Changing Linetype Scale to Existing Line

mgorecki
Collaborator
Collaborator

Hello All,

I have a simple  function that creates the lines in my drawing.

(defun CreateLine (p1 p2 lType)
 (entmake
  (list
   (cons 0 "LINE")
   (cons 10 p1)
   (cons 11 p2)
   (cons 6 lType)
   (cons 48 1.0)
  )
 )
)

 

Now I want to follow up after adding one particular line by changing it's linetype scale to 0.5.

So, here is my code:

 (CreateLine ln1Pt1 ln1Pt2 "Hidden")
 (setq lineToChange (entget (entlast)))
 (setq newLine (subst (cons 48 0.5) (assoc 48 lineToChange) lineToChange))
 (entmod newline)

 

This has absolutely no effect on the line that was just put in.

If anyone knows how to change the linetype scale for the particular line, please let me know.

 

Thanks in advance,

Mark

0 Likes
Accepted solutions (1)
1,019 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable

Your short program is for creating a NEW linetype entity You have to adjust your code to modify an existing linetype entity, if that's what you want to do.

0 Likes
Message 3 of 7

ВeekeeCZ
Consultant
Consultant
Accepted solution

The point is that the code is omitted if the value is 1, even if created that way.

Look at a list retrieved by (entget (entlast))... can you find code 48 there?

Solution would be like this:

 

  (setq d (entget (entlast)))
  (entmod (if (setq a (assoc 48 d))
	    (subst '(48 . 0.5) a d)
	    (append d '((48 . 0.5)))))

BTW This is very common... see HERE - there are listed default values if code is omitted.

0 Likes
Message 4 of 7

mgorecki
Collaborator
Collaborator

Yes, the function creates the line, but the code following the function call is supposed to change the new line, but it doesn't.

This is the code that' supposed to change the newly created line, right after the function call:

(CreateLine ln1Pt1 ln1Pt2 "Hidden")
 (setq lineToChange (entget (entlast)))
 (setq newLine (subst (cons 48 0.5) (assoc 48 lineToChange) lineToChange))
 (entmod newline)

 

0 Likes
Message 5 of 7

mgorecki
Collaborator
Collaborator

Thank you very much!!  That did the trick. 

Message 6 of 7

Anonymous
Not applicable

Okay, I didn't understand what you were trying to do. I would have just created the new (original) linetype already at the half scale or have it prompt me for the ltscale i wanted to use. My bad.

0 Likes
Message 7 of 7

mgorecki
Collaborator
Collaborator

Hi, no problem.  Thank you for your input.  I did think about changing the function to accept ltscale like you suggested, but it was only going to be used for this one line, so I was hoping to find another way to do it.

0 Likes