Jump to content

lisp to draw polyline with specifc width + layer


masterfal

Recommended Posts

Hi All,

 

I have a lisp routine set up where when i type the command and then choose a polyline, it will modify this polyline to have a set thickness. It doesn't work on normal lines though. I have to use a different routine to change a line into a polyline before it sets the thickness

Is it possible to set up so that the same command can work on both lines or polylines? And Is it also possible to specify a layer to put this polyline onto?

I'd like to make it so typing B1 will make a polyline with width of 50 in a layer called _beams

 

 

(defun c:b1 () (command "pedit" pause "w" "50" ""))

 

Link to comment
Share on other sites

I have a lisp that I am trying to work out the last step it allows you to do any width by type P23 ie a pline 23 wide you can type P plus any number. It makes a new pline with a width but you could edit it and do a is it a line or a pline  then pedit the entity. For any one interested see code attached problem is in color option. 

 

What about something like this. The multi getvals can be changed so it remembers the layer and width.

 

 

image.png.047194ec504c8045cb78a3e28ec9b4d5.png

 

(defun c:pedwid  ( / ans entis lay wid )
(while (setq ent (car (entsel "\nPick an object to make pline width:")))
(setq entis (cdr (assoc 0 (entget ent))))
(if (not AH:getvalsm)(load "Multi Getvals.lsp"))
(setq ans (AH:getvalsm (list "Please choose" "layer name " 25 24 "Your layer name" "Width " 8 7 "20" )))
(setq lay (nth 0 ans))
(setq wid (atof (nth 1 ans)))
(cond 
((= entis "LINE")(command "Pedit" ent "Y" "w" wid ""))
((= entis "ARC")(command "Pedit" ent "Y" "w" wid ""))
(if (= entis "LWPOLYLINE")(command "Pedit" ent "w" wid ""))
((Alert "Object chosen can not be made into a pline"))
)
(command "chprop" (entlast) "" "LA" lay "")
)
(princ)
)
(c:pedwid)

Multi GETVALS.lsp

pline arc offset.lsp

Edited by BIGAL
Link to comment
Share on other sites

thats pretty cool. converts to polyline with thickness but doesn't seem to want to change layer? just puts it in whatever the current layer is

Link to comment
Share on other sites

can it be set up so skips the prompt to input thickness & layer name? i only need it to do 3 different thicknesses 50, 100, 200 and all in same layer (_beams)

Was hoping to get it set up with 3 different commands that changes the line to those actual widths

B1 would be 50 thick in _beams layer

B2 would be 100 thick in _beams layer

B3 would be 200 thick in _beams layer

Link to comment
Share on other sites

Try this

 

(defun c:b1 ( /) (pedwid 50.0 "_beams layer"))
(defun c:b2 ( /) (pedwid 100.0 "_beams layer"))
(defun c:b3 ( /) (pedwid 200.0 "_beams layer"))

(defun pedwid  (wid lay / entis )
(while (setq ent (car (entsel "\nPick an object to make pline width:")))
(setq entis (cdr (assoc 0 (entget ent))))
(cond 
((= entis "LINE")(command "Pedit" ent "Y" "w" wid ""))
((= entis "ARC")(command "Pedit" ent "Y" "w" wid ""))
(if (= entis "LWPOLYLINE")(command "Pedit" ent "w" wid ""))
((Alert "Object chosen can not be made into a pline"))
)
(command "chprop" (entlast) "" "LA" lay "")
)
(princ)
)

 

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

thanks for having a look. when i try this it it only lets me select 1 line at a time and after choosing the line i have press enter a couple of times to end the command. anyway to get around those things?

Link to comment
Share on other sites

ahh i was so close.. i was adding the additional "" at the ends of the lines below instead of where you showed to add it

((= entis "LINE")(command "Pedit" ent "Y" "w" wid ""))
((= entis "ARC")(command "Pedit" ent "Y" "w" wid ""))
(if (= entis "LWPOLYLINE")(command "Pedit" ent "w" wid ""))
Link to comment
Share on other sites

ahhhh damn it. may have done this for nothing.. didn't realise thick polylines don't print out the same as a solid shade even though they look identical on screen.. is this normal?

 

on screen:

image.thumb.png.164c4243419bf955a0b166785b5fdc60.png

 

 

 

print:

image.png.7d6cae7cd09c4100ff5ff1d090b7500b.png

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