Jump to content

Lisp to convert plan dimension output to show the actual dimension at a given pitch / angle.


Cladding Connexions

Recommended Posts

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!!

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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 .

 

image.png.9593c75aea1a033687e977abf132602a.png

Link to comment
Share on other sites

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

Link to comment
Share on other sites

That, my friend, is a work of art! Very clever.

 

Thanks very much for your efforts, its much appreciated.

🍻

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...