Cladding Connexions Posted August 8, 2019 Posted August 8, 2019 Good Morning All, All of our drawings are produced in 2D AutoCAD, generally building elevations, roof plans and sectional details. What I want to be able to do is measure a dimension on the plan of a roof, but, use a lisp to apply a factor to this so that the output dimension shows the length at the pitch of the roof... In other words if the plan dimension was 5000mm, but the roof pitch was known to be 10 degrees, the output of that dimension would show 5077mm. Or, at 15 degrees, the output would show 5176mm, etc, etc. What I would also like to do is apply this lisp individually or to a group of dimensions. Hope this makes sense!! Quote
Emmanuel Delay Posted August 8, 2019 Posted August 8, 2019 How do we know the 15° angle pitch? Do you want to type the angle, or can lisp read it from somewhere on the dwg? Could you upload a (simplified) example? Quote
Cladding Connexions Posted August 8, 2019 Author Posted August 8, 2019 Hi Emmanuel, As the roof pitch varies between projects I think this would be a variable that the user inputs when using the lisp. One thing I didn't mention was that all of our drawings are drawn in model space and annotated including dimensions in paper space . Quote
Emmanuel Delay Posted August 8, 2019 Posted August 8, 2019 Happy with this? First draw the dimensions normally. Then we will put a Text Override on those dims COMMAND CFP (for Correct Piched Roof) - select the Angle dim that says 15°, Or Press Enter and then type an angle value - in a while loop select the dims to correct. (Maybe you don't want 3 decimals, then change the 3 on the line that has the RTOS function) DWG in attachment to test on (defun setTextOverride (obj textoverride / a b) (setq a (entget obj)) ; This is the guts of the entity you are working (setq b (assoc 1 a)) ; This contains the 'old' text string (setq c (cons 1 textoverride)) ; This is your 'new' assoc 1 (setq a (subst c b a)) ; You''re rewriting the definition for assoc 1 in ;;your entity (entmod a) ; and now you update the entity. ) (defun deg2rad (d / ) (* pi (/ d 180.)) ) (defun c:cfp ( / angle_ent dim_ent ang val corrected_value) (setq angle_ent (entsel "\nSelect Angle Dim or press Enter to set the angle manually: ")) (if angle_ent (setq ang (cdr (assoc 42 (entget (car angle_ent))))) ;; or manually (setq ang (deg2rad (getreal "\nSet Angle in degrees: "))) ) (while (setq dim_ent (entsel "\nSelect pitched Dim to correct: ")) (setq val (cdr (assoc 42 (entget (car dim_ent))))) (setq corrected_value (/ val (cos ang))) ;; divide by the cosinus of the angle (setTextOverride (car dim_ent) (rtos corrected_value 2 3) ) ;; That 3 is the precision, you may want te change this ) (princ) ) pitched_roof.dwg Quote
Cladding Connexions Posted August 8, 2019 Author Posted August 8, 2019 That, my friend, is a work of art! Very clever. Thanks very much for your efforts, its much appreciated. Quote
BIGAL Posted August 9, 2019 Posted August 9, 2019 (edited) As you are changing the dim text maybe add that its slope length "5170 SL" Edited August 9, 2019 by BIGAL Quote
Emmanuel Delay Posted August 12, 2019 Posted August 12, 2019 Yes, in that case: (setTextOverride (car dim_ent) (strcat (rtos corrected_value 2 3) " SL")) Quote
Recommended Posts
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.