calculation

calculation

Gaganpatel
Collaborator Collaborator
3,543 Views
29 Replies
Message 1 of 30

calculation

Gaganpatel
Collaborator
Collaborator

 

Dear Sir,

I want calculation auto lisp program. out put text are attributes block.

Please find the attachment.

 

0 Likes
Accepted solutions (1)
3,544 Views
29 Replies
Replies (29)
Message 21 of 30

Kent1Cooper
Consultant
Consultant

In simplest terms, using whatever the current Text Style and height are, on the current Layer, and assuming the current Style does not have a fixed height, and with all issues of relative positioning, etc. to be dealt with if you don't want them just stacked up, here's one way to do it:

 

(defun C:DOIT ()
  (setq
    Base (getdist "\nBase: ")
    Altitude (getdist "\nAltitude: ")
    1stSlope (sqrt (+ (expt Altitude 2) (expt Base 2)))
    2ndSlope (sqrt (+ (expt 1stSlope 2) (expt Base 2)))
    TSlopeTanB (/ Base Altitude)
    2TanB (* TSlopeTanB 2)
    Face (/ 1stSlope Altitude)
    Dev (/ 2ndSlope Altitude)
    FSlopeTanB (/ Base 1stSlope)
    SecB (/ Dev Face)
  )
  (command "_.text" (getvar 'viewctr) "" "" (strcat "1st Slope = " (rtos 1stSlope 2 4)))
  (command "_.text" "" (strcat "2nd Slope = " (rtos 2ndSlope 2 4)))
  (command "_.text" "" (strcat "TanB = " (rtos TSlopeTanB 2 9)))
  (command "_.text" "" (strcat "2TanB = " (rtos 2TanB 2 9)))
  (command "_.text" "" (strcat "Face = " (rtos Face 2 9)))
  (command "_.text" "" (strcat "Dev = " (rtos Dev 2 9)))
  (command "_.text" "" (strcat "TanB = " (rtos FSlopeTanB 2 9)))
  (command "_.text" "" (strcat "SecB = " (rtos SecB 2 9)))
)

You can specify the Base and Altitude by either typing in values or picking points on-screen.

 

I notice that you're still calling for two with the same heading....

Kent Cooper, AIA
0 Likes
Message 22 of 30

Gaganpatel
Collaborator
Collaborator

Thank You very much sir

calculation result is ok,but one change

Please adding red mark text this position.

1st Slope

2nd Slope

 

TOWER SLOPE

TanB

2TanB

Face

Dev

 

IN FACE SLOPE

TanB

SecB

 

 

 

0 Likes
Message 23 of 30

Kent1Cooper
Consultant
Consultant
Accepted solution
(defun C:DOIT ()
  (setq
    Base (getdist "\nBase: ")
    Altitude (getdist "\nAltitude: ")
    1stSlope (sqrt (+ (expt Altitude 2) (expt Base 2)))
    2ndSlope (sqrt (+ (expt 1stSlope 2) (expt Base 2)))
    TSlopeTanB (/ Base Altitude)
    2TanB (* TSlopeTanB 2)
    Face (/ 1stSlope Altitude)
    Dev (/ 2ndSlope Altitude)
    FSlopeTanB (/ Base 1stSlope)
    SecB (/ Dev Face)
  )
  (command "_.text" (getvar 'viewctr) "" "" (strcat "1st Slope = " (rtos 1stSlope 2 4)))
  (command "_.text" "" (strcat "2nd Slope = " (rtos 2ndSlope 2 4)))
  (command "_.text" "" " " "_.text" "" "Tower Slope" "_.chprop" "_last" "" "_color" 1 "")
  (command "_.text" "" (strcat "TanB = " (rtos TSlopeTanB 2 9)) "_.chprop" "_last" "" "_color" "_bylayer" "")
  (command "_.text" "" (strcat "2TanB = " (rtos 2TanB 2 9)))
  (command "_.text" "" (strcat "Face = " (rtos Face 2 9)))
  (command "_.text" "" (strcat "Dev = " (rtos Dev 2 9)))
  (command "_.text" "" " " "_.text" "" "In Face Slope" "_.chprop" "_last" "" "_color" 1 "")
  (command "_.text" "" (strcat "TanB = " (rtos FSlopeTanB 2 9)) "_.chprop" "_last" "" "_color" "_bylayer" "")
  (command "_.text" "" (strcat "SecB = " (rtos SecB 2 9)))
)
Kent Cooper, AIA
Message 24 of 30

Gaganpatel
Collaborator
Collaborator

Thank You Very Much sir

0 Likes
Message 25 of 30

ekjerside
Contributor
Contributor

@Kent1Cooper 

 

I am about to do some lisp coding of something almost similar but it is another calculations and I need to put the results inside an attribute inside a block. 

 

And:

 

1. How do put the calculation results inside a block with attributes?

2. How do hit the right attribute with the right named tag?

 

Can you or somebody hint me in any direction or maybe some code examples.

 

 

0 Likes
Message 26 of 30

Kent1Cooper
Consultant
Consultant

Try:
(setpropertyvalue BlockEntityName "AttributeTag" "theValue")

Kent Cooper, AIA
0 Likes
Message 27 of 30

Sea-Haven
Mentor
Mentor

This is a method without using setproperty, the tag name is oldtagn and the string to be entered is newstr, this code is part of looping through all layouts. Not all Cad programs support setproperty.

 

(if (setq ss1 (ssget "x"  (list (cons 0 "INSERT") (cons 2 bname)(cons 410 tabname))))
      (foreach att (vlax-invoke (vlax-ename->vla-object (ssname SS1 0 )) 'getattributes)
        (if (= oldtagn (strcase (vla-get-tagstring att)))
           (vla-put-textstring att newstr)
        )
      )

  

0 Likes
Message 28 of 30

Kent1Cooper
Consultant
Consultant

@Sea-Haven wrote:

.... Not all Cad programs support setproperty.


[But AutoCAD does.  This is, it should be noted, an AutoCAD Forum specifically, not an "all Cad programs" Forum.]

Kent Cooper, AIA
0 Likes
Message 29 of 30

Sea-Haven
Mentor
Mentor

Lots of ZWCAD BRICSCAD INTELICAD to mention a few users also look here for answers.

0 Likes
Message 30 of 30

Kent1Cooper
Consultant
Consultant

Are there no Forums for those programs, where people would not be inconvenienced by finding they can't use some of the solutions?

Kent Cooper, AIA
0 Likes