Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Entering functions

11 REPLIES 11
SOLVED
Reply
Message 1 of 12
SRB_Math
435 Views, 11 Replies

Entering functions

Is it possible to enter a function / equation to define a line / edge?

11 REPLIES 11
Message 2 of 12
pendean
in reply to: SRB_Math

Can you elaborate please?
Message 3 of 12
SRB_Math
in reply to: pendean

Can I enter an equation like y = 2x^3 + 3x +15, with a restricted domain to define a line, so that I can then rotate it on an axis to create a solid?

Message 4 of 12
doni49
in reply to: SRB_Math


@SRB_Math wrote:

Can I enter an equation like y = 2x^3 + 3x +15, with a restricted domain to define a line, so that I can then rotate it on an axis to create a solid?


I still have no idea what you mean by "with a restricted domain".  But you can perform calculations using the QUICKCALC command which should help you.

 



Don Ireland
Engineering Design Technician




If a reply solves your issue, please remember to click on "Accept as Solution". This will help other users looking to solve a similar issue. Thank you.


Please do not send a PM asking for assistance. That's what the forums are for. This allows everyone to benefit from the question asked and the answers given.

Message 5 of 12
Kent1Cooper
in reply to: SRB_Math


@SRB_Math wrote:

Can I enter an equation like y = 2x^3 + 3x +15, with a restricted domain to define a line, so that I can then rotate it on an axis to create a solid?


As far as I know, the answer is no, but one could pretty easily convert a function like that into an AutoLISP expression in a routine that would ask for the domain [minimum and maximum values for X] and a precision [how closely spaced in the X direction you want points calculated], calculate the Y values for each X position, and draw for example a Spline or Polyline along the calculated route; the Polyline version could then be smoothed with PEDIT's Fit or Spline option if desired.  Does that sound like it would work for you?

 

[By the way, an equation like that certainly wouldn't define a "Line" in AutoCAD's use of the word, but I think I know what you mean.]

 

For instance [minimally tested, and taking the default end tangent directions, without the usual controls, etc.]:

 

(defun C:EQUATION3 (/ mult3 mult2 mult1 const minX maxX inc n)
  (setq
    mult3 (getreal "\nMultiplier on X^3: ")
    mult2 (getreal "\nMultiplier on X^2: ")
    mult1 (getreal "\nMultiplier on X: ")
    const (getreal "\nConstant: ")
    minX (getreal "\nMinimum X value: ")
    maxX (getreal "\nMaximum X value: ")
    inc (getreal "\nPrecision [increment between X values]: ")
    n -1
  ); setq
  (command "_.spline")
  (repeat (1+ (fix (/ (- maxX minX) inc)))
    (command ; feed out to Spline command
      (list
        (setq x (+ minX (* inc (setq n (1+ n)))))
        (+
          (* mult3 (expt x 3))
          (* mult2 (expt x 2))
          (* mult1 x)
          const
        ); +
      ); list
    ); command
  ); repeat
  (command "" "" "")
); defun

 

In your example case, answer 0 for the multiplier on X^2.  All supplied answers can be positive or negative, whole or decimal numbers, etc.

Kent Cooper, AIA
Message 6 of 12
JDMather
in reply to: SRB_Math


@SRB_Math wrote:

Can I enter an equation like y = 2x^3 + 3x +15, with a restricted domain to define a line, so that I can then rotate it on an axis to create a solid?



You can do this in Autodesk Inventor with Equation Curves.
Here is an example (but not with your equation).
http://help.autodesk.com/view/INVNTOR/2015/ENU/?guid=GUID-8BF2EEB8-3A64-43F1-BA75-5ECBE357F08C
Students can download Inventor from http://www.autodesk.com/edcommunity

-----------------------------------------------------------------------------------------
Autodesk Inventor 2019 Certified Professional
Autodesk AutoCAD 2013 Certified Professional
Certified SolidWorks Professional


Message 7 of 12
kasperwuyts
in reply to: SRB_Math

How Autodesk would recommend doing it:
http://knowledge.autodesk.com/support/autocad/troubleshooting/caas/sfdcarticles/sfdcarticles/Draw-po...

Best regards
Kasper Wuyts
_______________________________________________________________________________
If this post solves your problem, clicking the 'accept as solution' button would be greatly appreciated.
Message 8 of 12
Kent1Cooper
in reply to: Kent1Cooper


@Kent1Cooper wrote:

....  All supplied answers can be positive or negative, whole or decimal numbers, etc.

 


...except that, of course I should have said, 'inc' can't be zero or negative -- it would be better done this way:

....

    inc (getdist "\nPrecision [increment between X values]: ")

....

Kent Cooper, AIA
Message 9 of 12
Kent1Cooper
in reply to: kasperwuyts


@kasperwuyts wrote:
How Autodesk would recommend doing it: ....

Wow -- that's pretty cumbersome, especially considering that you'd need to go through that entire rigmarole, including making a complete and distinct set of Excel and Word and .scr files separately for every such equation with different multipliers and constant and bounds that you want to draw.  If a Polyline such as that would make will do for you instead of a Spline, just take mine and remove the s from "_.spline" and the last two "" Enters from the (command) function that has three of them.

Kent Cooper, AIA
Message 10 of 12
SRB_Math
in reply to: Kent1Cooper

Thank you.

Message 11 of 12
SRB_Math
in reply to: JDMather

Cheers. Like it.
Message 12 of 12
Kent1Cooper
in reply to: SRB_Math


@SRB_Math wrote:

Is it possible to enter a function / equation to define a line / edge?


I came up with a more sophisticated routine for AutoCAD, PolynomialFunction.lsp with its PF command, to draw a Polynomial Function in the form Y = a series of descending powers of X with coefficient multipliers, and a constant.

 

It gives you the following choices:

A. whether to draw a Spline or a Polyline;
B. the X-Y axis intersection origin point to build it around [it puts a Point entity there for reference];

C. the degree [highest exponent on X -- I tried it even up to X^17];

D. the coefficient applied to each power of X [positive, negative or 0];

E. the constant number [positive, negative or 0];

F. the bounds [either as numbers relative to the origin or by picking points from which it will take their X coordinates];

G. the precision [increment in X direction between calculated values of Y].

 

And it remembers all your choices, and offers them as defaults on subsequent use.  See a few additional things to know, in the comments at the top of the file.

Kent Cooper, AIA

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost