[Shocker CAD!]You can never modify a spline curve in an LSP script?[About Knots and Uniform!]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I need to generate the required spline curve automatically with an LSP script: directly generated Fit-Uniform-Spline (not first generated and then set to "Fit-Uniform").
But I realized that I can't do it, it's a bit complicated, please hear me out ......
(setvar "SPLMETHOD" 0)
(setvar "SPLKNOTS" 2)
At first I used the method of changing system variables to try to solve the problem quickly.
Result: entmake and command can't inherit these two system variables, it's not that the change didn't work, but these two system variables are only valid for manual input, and with code you can only generate Fit-Chord-Spline.
'(72 . 2)
I didn't give in and tried to set it up directly with entmake.
Result: The CAD website doesn't have a detailed description of "SPLINE (DXF) Group code 72", and ChatGpt tells me that 2 stands for "Uniform", but no matter what I change it to, the resulting spline is always Fit-Chord-Spline.
(initcommandversion 1)
(command "-SPLINE" "Method" "Fit" "Knots" "Uniform")
(initcommandversion 0)
Still haven't given up! This time I used command to set the parameters directly!
Result: no! It seems that since a long time ago CAD doesn't support calling "M" and "K" via command, and restoring the old version with initcommandversion didn't work, so I suspect that these functions have been completely removed.
(setq splineObj (vla-AddSpline modelSpace points_right_variant nil nil))
(vla-put-KnotParameterization splineObj acUniformKnotParameterization)
(vla-put-Method splineObj acFitMethod)
I'm not convinced! Tried to use the unfamiliar ActiveX, thinking that utilizing the API would surely work.
Result: I wrote half a day's worth of code and couldn't write a script that would generate a spline curve properly! ActiveX was too difficult and I didn't understand it at all!
My core need:
(1) The best result is to generate Fit-Uniform-Spline directly using entmake or command, either by inheriting system variables or by setting it directly with a command.
(2) Barely acceptable result is to generate Fit-Chord-Spline and then modify it to Fit-Uniform-Spline after generating Fit-Chord-Spline.
(3) If the esteemed big guys are willing, I'd also like to get an LSP script that generates Fit-Uniform-Spline via ActiveX API, mainly because I'm curious about how to implement it.
First time in the community, hopefully some of the big guys can help me out as a newbie who doesn't know anything.
As a final note, my CAD version is the mechanical version of the 2024, thanks!