Author Topic: How can I get C value?  (Read 3400 times)

0 Members and 1 Guest are viewing this topic.

HasanCAD

  • Swamp Rat
  • Posts: 1422
How can I get C value?
« on: February 17, 2013, 03:42:22 AM »
I have irruguler falce ceiling and I know start and end levels
is there a formula to get a point level on this slope
for example
A=100
B=150
L1=2000
L2=1500
How can I get C value?
« Last Edit: February 17, 2013, 03:54:07 AM by HasanCAD »

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
Re: How can I get C value?
« Reply #1 on: February 17, 2013, 04:06:09 AM »
I think these will work if you can get point "A" but you should wait for better replies:
 
pointX = x + distance * cos(angle)
pointY = y + distance * sin(angle)

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: How can I get C value?
« Reply #2 on: February 17, 2013, 04:09:07 AM »
I think these will work if you can get point "A" but you should wait for better replies:
 
pointX = x + distance * cos(angle)
pointY = y + distance * sin(angle)

Thnx for reply but I need a formula without angle

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
Re: How can I get C value?
« Reply #3 on: February 17, 2013, 04:10:54 AM »
Aw... sorry. Was thinking you could get the angle from A and B.

pkohut

  • Bull Frog
  • Posts: 483
Re: How can I get C value?
« Reply #4 on: February 17, 2013, 04:13:14 AM »
I have irruguler falce ceiling and I know start and end levels
is there a formula to get a point level on this slope
for example
A=100
B=150
L1=2000
L2=1500
How can I get C value?

Not validated...
(B - A) / L1 * L2 + A
New tread (not retired) - public repo at https://github.com/pkohut

pBe

  • Bull Frog
  • Posts: 402
Re: How can I get C value?
« Reply #5 on: February 17, 2013, 04:25:50 AM »
I think these will work if you can get point "A" but you should wait for better replies:
 
pointX = x + distance * cos(angle)
pointY = y + distance * sin(angle)

Thnx for reply but I need a formula without angle

Code: [Select]

(setq A    100.0
      B    150.0
      L1   2000.0
      L2   1500.0)
(+ (* (/ (- B A) L1) L2) A)
oops.. formatting....
« Last Edit: February 17, 2013, 04:35:30 AM by pBe »

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: How can I get C value?
« Reply #6 on: February 17, 2013, 05:17:10 AM »
Similar scenario to dividing a line by a factor:
Code - Auto/Visual Lisp: [Select]
  1. (setq A 100.0 B 150.0 L1 2000.0 L2 1500.0)
  2. (setq C (* (+ A B) (/ L2 L1))) ;Or
  3. (setq C (/ (* (+ A B) L2) L1))
The equivalent (in-line) algebraic formula reads:

Now to go further: How do you obtain the points of the slope? Probably from something like a line's endpoints (entget), or using the getpoint function? If so then your variables might contain something like this:
Code - Auto/Visual Lisp: [Select]
  1. (setq A (getpoint "Pick A") B (getpoint "Pick B"))
  2. (prompt (strcat "L1 = " (rtos (setq L1 (abs (- (cadr B) (cadr A))))) "\n"))
  3. (setq L2 (getdist "Pick L2"))
  4. (setq C (mapcar '(lambda (a b) (/ (* (+ a b) L2) L1)) A B))
« Last Edit: February 17, 2013, 05:28:58 AM by irneb »
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

pBe

  • Bull Frog
  • Posts: 402
Re: How can I get C value?
« Reply #7 on: February 17, 2013, 05:29:31 AM »

(+ (* (/ (- B A) L1) L2) A)
137.50

(* (+ A B) (/ L2 L1))

187.5
(/ (* (+ A B) L2) L1)
187.5


HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: How can I get C value?
« Reply #8 on: February 17, 2013, 06:06:38 AM »
In fact i have attributes having these values
Code: [Select]
(defun c:CLC (/
      ATTA ATTAP ATTASTR ATTASTRCH ATTASTRCHF ATTAVL
      ATTB ATTBP ATTBSTR ATTBSTRCH ATTBSTRCHF ATTBVL
      ATTC ATTCP ATTCVL CVALUE
      DIFF DIS1 DIS2 DOC
      )

  (vl-load-com)

  (defun *error* ( msg ) (and doc (_EndUndo doc)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (princ))
  (defun _StartUndo ( doc ) (_EndUndo doc) (vla-StartUndoMark doc))
  (defun _EndUndo ( doc ) (if (= 8 (logand 8 (getvar 'UNDOCTL))) (vla-EndUndoMark doc)))
  (defun DocActv (/ doc spc ) (setq doc (vla-get-ActiveDocument (vlax-get-acad-object))) (setq spc (if (or (eq AcModelSpace (vla-get-ActiveSpace doc)) (eq :vlax-true   (vla-get-MSpace doc))) (vla-get-ModelSpace doc) (vla-get-PaperSpace doc))))
  (defun round (number by) (if (zerop by) number (+ (* (fix (/ number (setq by (abs by)))) by) (if (< (* 0.5 by) (rem number by)) by 0))))

  (while
    (progn
    (setq ATTa (car (nentsel "\nSelect A: "))
  ATTaVL (vlax-ename->vla-object ATTa)
  ATTaSTR (VLA-GET-TEXTSTRING ATTaVL)
  ATTaSTRch (vl-string-left-trim "EL. " ATTaSTR)
  ATTaSTRchF (atof ATTaSTRch))

    (setq ATTb (car (nentsel "\nSelect B: "))
  ATTbVL (vlax-ename->vla-object ATTb)
  ATTbSTR (VLA-GET-TEXTSTRING ATTbVL)
  ATTbSTRch (vl-string-left-trim "EL. " ATTbSTR)
  ATTbSTRchF (atof ATTbSTRch)
  diff (abs (- ATTbSTRchF ATTaSTRchF)))

    (setq ATTaP (getpoint "\nSelect point A: ")
  ATTbP (getpoint "\nSelect point B: ")
  ATTcP (getpoint "\nSelect point C: ")
  dis1 (getdist ATTaP ATTcP)
  dis2 (getdist ATTaP ATTbP))

    (setq cValue (strcat "EL. " (itoa (Round (+ (* (/ DIFF dis2) dis1) ATTaSTRchF) 5))))

    (setq ATTc (car (nentsel "\nSelect C: "))
  ATTcVL (vlax-ename->vla-object ATTc))

    (vla-put-TextString ATTcVL cValue)
    ))
  )

In the same line. Is there deference between
Code: [Select]
(setq ATTa (car (nentsel "\nSelect A: "))
  ATTaVL (vlax-ename->vla-object ATTa)
  ATTaSTR (VLA-GET-TEXTSTRING ATTaVL)
  ATTaSTRch (vl-string-left-trim "EL. " ATTaSTR)
  ATTaSTRchF (atof ATTaSTRch))
And
Code: [Select]
(setq ATTaSTRchF
       (atof (vl-string-left-trim
       "EL. "
       (VLA-GET-TEXTSTRING
(vlax-ename->vla-object
   (car (nentsel "\nSelect A: "))
)
       )
     )
       )
)

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: How can I get C value?
« Reply #9 on: February 17, 2013, 07:35:37 AM »
The equivalent (in-line) algebraic formula reads:


Not quite...


irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: How can I get C value?
« Reply #10 on: February 17, 2013, 09:42:32 AM »
Ah yes sorry ... that is incorrect of me.  :-[
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.