Author Topic: How to combine multiple commands in one lisp?  (Read 5839 times)

0 Members and 1 Guest are viewing this topic.

Vikram

  • Newt
  • Posts: 50
How to combine multiple commands in one lisp?
« on: November 12, 2019, 01:56:42 AM »
I want these commands to be executed sequentially.
1) Pedit - join: I will make line polyline.
2) Pedit-> Spline
3) Explode that polyline

Dlanor

  • Bull Frog
  • Posts: 263
Re: How to combine multiple commands in one lisp?
« Reply #1 on: November 12, 2019, 05:44:15 AM »
Try this. It will take a Selection Set of Lines, turn them into a pline, spline it then explode it. Adjust fuzz to suit your need. 

Code - Auto/Visual Lisp: [Select]
  1. (defun c:test ( / pea fuzz ss )
  2.   (setq ss nil
  3.            pea (getvar 'peditaccept)
  4.           fuzz 1.0e-6
  5.   )
  6.   (setvar 'peditaccept 1)
  7.   (prompt "\nSelect Lines : ")
  8.   (setq ss (ssget '((0 . "LINE"))))
  9.   (command "_PEDIT" "M" ss "" "_J" fuzz "_S" "")
  10.   (command "_EXPLODE" (entlast))
  11.   (setvar 'peditaccept pea)
  12.   (princ)
  13. )
  14.  
« Last Edit: November 16, 2019, 07:22:30 AM by Dlanor »

Vikram

  • Newt
  • Posts: 50
Re: How to combine multiple commands in one lisp?
« Reply #2 on: November 13, 2019, 07:23:54 AM »
Thank you very much Dlanor!! :D
Can I know what is the fuzz? And how will it affect my polyline?
Actually I also wanted to add one more function in that lisp. I want to convert those exploded vertices back into polyline. Is that possible? Because after doing spline and explode,vertices in line will increase. For example 30 vertices will become 150
« Last Edit: November 13, 2019, 08:35:19 AM by Vikram »

Dlanor

  • Bull Frog
  • Posts: 263
Re: How to combine multiple commands in one lisp?
« Reply #3 on: November 13, 2019, 06:23:16 PM »
When you try to join two lines using pedit, it expects two ends to meet at a point, if they don't then it won't join them. It does however allow a fuzz factor. This is the amount by which two ends can differ but be accepted as the same i.e. a small gap between the ends of lines. Increasing the fuzz factor (making it larger) allows for bigger gaps but may alter the order lines are added.

I have set it at 1.0e-6 (0.000001).

Quote
Actually I also wanted to add one more function in that lisp. I want to convert those exploded vertices back into polyline. Is that possible? Because after doing spline and explode,vertices in line will increase. For example 30 vertices will become 150

Not sure I fully understand what you want. If you just want a polyline then don't explode it, it is a still a polyline object with spline fit curves, not a spline object. 

Vikram

  • Newt
  • Posts: 50
Re: How to combine multiple commands in one lisp?
« Reply #4 on: November 13, 2019, 10:07:50 PM »
Thanks for the explanation!
Actually I want these followings steps to happen in single lisp.
1. I will select amd give data points to a lisp
2. Pedit->Join
3. Pedit ->Spline
4. Explode
5.Pedit->join

I just want to add up the last 5th step in your previous lisp. So that I can make the the exploded points pline again

Dlanor

  • Bull Frog
  • Posts: 263
Re: How to combine multiple commands in one lisp?
« Reply #5 on: November 14, 2019, 05:25:20 AM »
I'm missing something here.

Before you explode the line, it is a pline not a spline. By exploding and joining you will end up with the same pline you had before exploding. If you want the new vertices as points you need to use the  'coordinates property of the pline.

What exactly are you trying, as there may be an easier way of getting the end result
« Last Edit: November 14, 2019, 05:38:55 AM by Dlanor »

ScottMC

  • Newt
  • Posts: 191
Re: How to combine multiple commands in one lisp?
« Reply #6 on: November 14, 2019, 10:45:18 PM »
Also a tool by "(Gile)" to clean up those extra points!
https://www.theswamp.org/index.php?topic=19865.msg244892#msg244892


Vikram

  • Newt
  • Posts: 50
Re: How to combine multiple commands in one lisp?
« Reply #7 on: November 16, 2019, 12:02:42 AM »
Dlanor I tried your lisp. But its not working. I'm getting this Invalid input
Select Lines :
Select entities or [FILter/Qselect]:
Entities in set: 1
Select entities or [FILter/Qselect]:
Opposite corner:
Entities in set: 293
Select entities or [FILter/Qselect]:
Command: _PEDIT
Select polyline to edit or [Multiple]: M
Select entities:
The entity selected is not a polyline.  Turn it into one? [Yes/No] <Y> _JUnable to recognize entry.  Please try again.
The entity selected is not a polyline.  Turn it into one? [Yes/No] <Y> 0.000001Unable to recognize entry.  Please try again.
The entity selected is not a polyline.  Turn it into one? [Yes/No] <Y> _SUnable to recognize entry.  Please try again.
The entity selected is not a polyline.  Turn it into one? [Yes/No] <Y> Unable to recognize entry.  Please try again.Invalid
Invalid input
Command: '_PMTHIST
« Last Edit: November 16, 2019, 12:12:46 AM by Vikram »

BIGAL

  • Swamp Rat
  • Posts: 1409
  • 40 + years of using Autocad
Re: How to combine multiple commands in one lisp?
« Reply #8 on: November 16, 2019, 12:50:07 AM »
Dlanor look at this explains what now is 5 individual posts trying to solve one problem.

http://www.theswamp.org/index.php?topic=55530.0
A man who never made a mistake never made anything

Vikram

  • Newt
  • Posts: 50
Re: How to combine multiple commands in one lisp?
« Reply #9 on: November 16, 2019, 01:20:11 AM »
What this topic have to do with making curve smooth? I just want a lisp to combine multiple commands. Yes I did that mistake before and I'm not able to delete topics.

Dlanor

  • Bull Frog
  • Posts: 263
Re: How to combine multiple commands in one lisp?
« Reply #10 on: November 16, 2019, 07:20:01 AM »
I have amended the code in my original post. I had forgotten to set peditaccept  :opps:


Vikram

  • Newt
  • Posts: 50
Re: How to combine multiple commands in one lisp?
« Reply #11 on: November 18, 2019, 01:31:06 AM »
Thanks a lot Dalanor it helped!! :D
You also need to remove fuzz near '_S' in this line
Code: [Select]
  (command "_PEDIT" "M" ss "" "_J" "_S" "")