Jump to content

exploding last selection


masterfal

Recommended Posts

Hi All,

 

I'm trying to create a lisp routine to run the centerline command then select the line just generated and explode it.

 

I can get it to create the centerline, and then pick the line

 

(defun c:clxo  () (command "centerline" pause pause)
(setq sel1 (ssget "l")) 
(sssetfirst nil sel1)
(princ)
)

but when i add the explode line into it, it doesn't explode.. what am i missing?

 

(defun c:clxo  () (command "centerline" pause pause)
(setq sel1 (ssget "l")) 
(sssetfirst nil sel1)
(command "explode")
(princ)
)

Link to comment
Share on other sites

You can not explode a linetype, do you want individual line repeating sequences ? There may be a way with a different command.

 

A easy way of last object is use (setq sel1 (entlast)) in your case why not "explode" "last" ""

Link to comment
Share on other sites

centerline is an object type (as well as linetype.. bit confusing I know). in 2017 theres a default command called 'centerline'

 

after running it you click one line, click another line and it draws a line central as a 'centerline' . my issue with it is that you are unable to offset this centerline (or do a few other modifications) unless its exploded and turned into a regular line.

 

thought I could save time by combining it all. ie. run the centerline command, then explode that line. then after its exploded I can run this double offset lisp I've got which offsets a line equally on both sides

CENTERLINE.png

Link to comment
Share on other sites

Very interesting. You made me open 2017 and use the new command CENTERLINE.

 

With that being said, I see that the centerline command asks the user to select a first line, then a second line, and places a centerline object between them. A new entity type I was unaware of, and that cannot be offset. Interesting.

Command: CENTERLINE

Select first line:
Select second line:
Command:
Command: LI LIST 1 found

              CENTER LINE  Layer: "0"
                           Space: Model space
                  Color: BYLAYER    Linetype: "CENTER2"
                  Handle = 1010a33
            Associative: Yes
            Start Extension = 0.120000, End Extension = 0.120000
            From point, X= 3576.995446  Y= 1318.941228  Z=0.000000
            To point,   X= 3838.233877  Y= 1057.702796  Z=0.000000
            Length = 369.446933
Command: O OFFSET
Current settings: Erase source=No  Layer=Source  OFFSETGAPTYPE=0
Specify offset distance or [Through/Erase/Layer] <Through>:  Specify second point:
Select object to offset or [Exit/Undo] <Exit>:
Cannot offset that object.

 

So, I thought I would treat this similar to adding lines to a selection set to generate a polyline afterward, and dug up a snippet from an old code, and it works:

 

(progn
 (setq Center1 (entlast))
 (setq ssCenterline (ssadd))
 (ssadd Center1 ssCenterline)
 (vl-cmdf "_.explode" ssCenterline)
)

Link to comment
Share on other sites

genius! thanks so much. now I just need to work out how to run this double offset command on the line after its been exploded. not to sure how to continue the routine to include below..

 

(defun c:DOF (/ a b b1 p1 d pckbox)
(setq d 20 p1 nil pee (/ pi 2)e 3 pckbox (getvar "pickbox")line "                               ")
(if(= #parof nil)(setq #parof(/(getvar "viewsize")10)))
(princ "\nCurrent offset <")(princ #parof)
(setq answer(getstring ">: "))
(if (/= (atof answer) 0.0)(setq #parof(atof answer)))

(princ line)
(setvar "pickbox" pckbox)
(setq ent(entsel "\nPick the line: "))
(setq point(cadr ent))
(princ line)
       (setq side(getpoint "\nPick an offset side: "))
(setq dist(distance side point))(setq ang(angle side point))
(if(or(or(< ang 0.78)(> ang 5.5))(and(> ang 2.35)(< ang 3.92)))
	(setq ang(- 0 ang))(setq ang(- pi ang))
);end if
(setq other(polar point ang dist))
(command "offset" #parof ent side ent other "")
       (entdel(car ent))

(setvar "pickbox" pckbox)
(prin1)
)
(Prompt "\nType DOF to envoke the command")

Link to comment
Share on other sites

A simple thing in offset to have both sides is to use a -ve value, just take the start and end point direction does not matter use polar for a point at 90 off line then just do offset pt val then offset pt -val A right and left will appear.

Link to comment
Share on other sites

hijacking the thread for one second - the CENTERLINE command (2017) is great to create a bisector of two angled lines. And they are constrained to stay between the two lines, so if you drag an end point of one line the CENTERLINE will stay centered. You can also bisect between the CENTERLINE and the original line and any CENTERLINEs stay centered between the objects used to create them.

 

now back to regular programming... (pun intended)

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