Jump to content

Change LineTypeScale of Polyline After Drawing


JulianSmith

Recommended Posts

Hello,

 

Trying to get a LISP routine to work to set the LineTypeScale of an object after I have drawn it. I can get all of the commands to work manually, but I can't get them to work together. I think it might have something to do with the pause statement I use to get user  input when drawing the polyline. Does anyone have a suggestion for how I can better set the LineTypeCale for this object? I don't want to set the LineTypeScale for the entire drawing. Many thanks. Cheers.

 

 

(Defun C:TestPl ()
    (setvar "CMDECHO" 0)
    (setq plccLayer (getvar "clayer"))

    (COMMAND "-LAYER"         "MAKE"             "FIBER"     "COLOR"         "130" "FIBER"
                   "Ltype"  "FENCELINE1" "FIBER"     ""                     "PLINEWID"     "0.015"         "PLINE"
                     PAUSE
    )


    (setvar "clayer" plccLayer)
    (setvar "PLINEWID" 0.0)


      (setq ss (ssget "L"))
        (command "change" ss "" "p" "s" 0.25 "")

  
  (princ)
)

 

Link to comment
Share on other sites

On 2/23/2021 at 4:02 PM, JulianSmith said:

Trying to get a LISP routine to work to set the LineTypeScale of an object after I have drawn it. I can get all of the commands to work manually, but I can't get them to work together. I think it might have something to do with the pause statement I use to get user  input when drawing the polyline. Does anyone have a suggestion for how I can better set the LineTypeCale for this object? I don't want to set the LineTypeScale for the entire drawing. Many thanks. Cheers.

 

The reason is because it tries to run the other commands before you finish the "pline" command. You need to delay the operation of the rest of the routine until it is finished. It does not do this for you with only 1 PAUSE option.

 

Try This - note the "cmdactive" loop to pause the "pline" command until you are finished drawing the polyline (see my comments for other improvements):

(Defun C:TestPl (/ plccLayer oecho oplwid ss); Localize your variables
    (setq plccLayer (getvar "clayer") oplwid (getvar "plinewid") oecho (getvar "cmdecho"))
    
    (setvar "plinewid" 0.015) ;; Don't use command to set system variables.
    
    ;; You want CMDECHO set to 1 here so you can see pline prompts.
    ;; FYI - the "dot" before the command ensures that the true command is used (not redefined),
    ;; the "underscore" will translate command names and options for international versions.
    (COMMAND "._-LAYER" "_M" "FIBER" "_C" "130" "" "_L" "FENCELINE1" "" "" 
             "._PLINE"
    )
    
    ;; This loops the pause until the command is over.
    (while (= (logand (getvar "cmdactive") 1) 1)
		 (command pause)
	)
    
    ;; reset system variable back to original values.
    (setvar "clayer" plccLayer)
    (setvar "PLINEWID" oplwid)
    
    ;; Set cmdecho here to 0 to not see the change command.
    (setvar "CMDECHO" 0)
   
    (setq ss (ssget "L"))
    (command "._Change" ss "" "_P" "_S" 0.25 "")
    
    ;; Reset cmdecho back to original value.
    (setvar "cmdecho" oecho)
    (princ)
)

 

Edited by pkenewell
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

4 hours ago, pkenewell said:

 

Thanks pkenewell; it worked perfect! Thanks also for the lesson. I knew it was going to be a loop, I just couldn't figure out where to put it.

 

 

  • Like 1
Link to comment
Share on other sites

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