Jump to content

Simple add/remove fit points on a spline


vanowm

Recommended Posts

This is a complimentary to splinedit command, which allow add/remove fit points to a spline with one click. No need preselect existing fit point, it will automatically insert new fit point at the click location.

New command: spledit or sple

It has a "Closest" option:  when enabled will insert fit points on spline itself even when clicked away from the spline.

 

I use splines a lot to trace around images, so having ability simply click to add/remove fit points is a time saver.

 

One other thing I'd like to improve this upon is ability to drag the fit points around while mouse button is pressed down on it, and remove it after button released without moving mouse. So far, I have not found a way to do it...

 

As of 2024-05-02 5:54 there are 2 options "drag New" and "drag Existing". When enabled newly created fit point could be moved around, same for existing fit points when "drag Existing" is enabled. The reason for the second option is whether you want single click to delete a point, or two clicks, but with ability move it too.

 

 

 

 

 

 

 

 

 

 

spledit.lsp

Edited by vanowm
latest version 2024-05-02 5:54
Link to comment
Share on other sites

 

Video_2024-04-16_115628.gif.5031d3cae29218626c257a9bf1e68049.gif

 

Dynamically insert SPLINE FIT points

 

The code below, using XDRX - API,
Before trying the forum code, please download and install XDRX - API

 

xdcad/XDrx-API: Autolisp development library written in ObjectARX (github.com)

https://github.com/xdcad/XDrx-API

 

===================================

 

(defun c:xdtb_spldynfit (/ dynpt fitpnt inx lastpnt spl)
  (defun _callback (dynpt)
    (if (not (equal dynpt lastpnt))
      (xdrx-spline-setfitpointat spl inx dynpt)
    )
    (setq lastpnt dynpt)
  )
  (xdrx-begin)
  (xdrx-sysvar-push '("osmode" 512))
  (if (and
	(setq spl (car (xdrx-entsel (xdrx-string-multilanguage "\n拾取SPLINE<退出>:" "\nPick Spline<Exit>:")
				    '((0 . "spline"))
		       )
		  )
	)
	(xdrx-entity-redraw spl 1)
	(setq fitpnt (getpoint (xdrx-string-multilanguage "\n点取新增Fit点位置<退出>:" "\nClick to select the new Fit point location<Exit>:")))
	(setq inx (xdrx-spline-insertfitpointat spl fitpnt))
      )
    (progn
      (xdrx-entity-redraw spl 4)
      (xdrx-pointmonitor "_callback")
      (getpoint)
      (xdrx-pointmonitor)
    )
  )
  (xdrx-sysvar-pop)
  (xdrx-end)
  (princ)
)

 

Link to comment
Share on other sites

That looks very interesting, but...I'm a bit skeptical installing an exe file from a chinese website (especially that it appeared on github 6 hours ago as zip downloads, which is not what github is for!)

Link to comment
Share on other sites

12 minutes ago, vanowm said:

That looks very interesting, but...I'm a bit skeptical installing an exe file from a chinese website (especially that it appeared on github 6 hours ago as zip downloads, which is not what github is for!)

Putting it on github provides a convenient download link for foreign netizens.
It wasn't put up just 6 hours ago. It has been on github, but it was updated 6 hours ago.

Link to comment
Share on other sites

@vanowm  I'd like to suggest that you experiment with using Control Vertices for editig the shape of a spline.  Manipulating CVs can give you great dynamic curvature control without the risk of adding unwanted undulations. Keep in mind that the fewer the fit points, or CVs, the more likely that you will have a smoother curve.

When I want to trace a shape I make a first attempt by using the fit point method. 

splinedit edit move is then used to slightly move one of the fit points.  Once you move a fit point all of the fit points will dissapear from that point on you you can directly move CVs to edit the shape without needing to use splinedit e m.   Clicking on the spline highlights the CVs and you can click on one and drag it while dynamically seeing the change it makes.   If you need more shape control for a particular segment of the spline you can add a CV via splinedit  e a.

  

Link to comment
Share on other sites

@lrm The problem is I'm exporting my drawings to another program, which doesn't like CV splines. Also, in some cases you'd have to zoom way out in order to reach needed CV, which might be undesirable.

Link to comment
Share on other sites

 

@XDSoft is there a way show grips during transformation? I've tried add (SSSETFIRST nil (SSADD spl)) inside _callback function, it worked but made it unacceptably slow.

[EDIT]

NVM it needed to be added before (getpoint) line.

Edited by vanowm
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...