#1
|
||||
|
||||
How to inquire the area of a face??
Hi,
I'm writing a Lisp macro that needs to know the area of a face. I thought something should be possible with this: Code:
(get_vol_prop :for_face my_face :area) I've searched the help file, but haven't found any alternative; does anyone have a clue?? Thanks! Regards, Jaap |
#2
|
||||
|
||||
Re: How to inquire the area of a face??
Try wrapping the call inside sd-call-cmds.
Claus
__________________
CoCreate Modeling FAQ: http://www.clausbrod.de/CoCreateModeling/ |
#3
|
|||
|
|||
Re: How to inquire the area of a face??
Hi Jaap,
Try something like this: Code:
(sd-call-cmds (get_vol_prop :for_face my_face :area) :success (setq myresult *sd-action-result*) :failure (setq myresult nil) ) I hope this helps! andy
__________________
Andy Poulsen AI MAXTools: Dream. Design. Done. It's that easy! Add-ins bringing new functionality and speed to Creo Elements/Direct and CoCreate products. Now available for v17-v20+! See them in action at www.ai-maxtools.com and then try them for yourself -- FREE! |
#4
|
||||
|
||||
Re: How to inquire the area of a face??
Hi,
thanks, guys!! It works like a dream now It's actually used for the lisp tool below. It checks if a part contains faces that are just-not-orthogonal. In practise, we have had problems with assemblies where half of the parts were "just-not-aligned" in X-, Y- or Z- direction. We found the Draft Analysis tool a bit heavy for checking the parts, and the new lisp tool presents the "problem faces" in a similar way as "keep results" from the clash check. Here's the code: Code:
(in-package :JAAPS_TOOLS) (use-package :OLI) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (sd-defdialog 'Highlight_Scheef :dialog-title "Check Ortho Faces" :variables '( (partje :value-type :part :modifies nil :title "Parts" :multiple-items t) (bovengrens :value-type :number :initial-value 1.01 :title "Upper Limit") (ondergrens :value-type :number :initial-value 1.00001 :title "Lower Limit") (oude_weg :value-type :boolean :initial-value t :title "Del Old Result" :toggle-type :wide-toggle) ) :local-functions '( (doit () (if (and (equal oude_weg T) (not (equal (sd-pathname-to-obj "/schevevlakken") NIL))) (delete_3d "/schevevlakken") ()) ;dus: oude_weg aangevinkt, en schevevlakken bestaat (setf vlakjes (sd-call-cmds (get_selection :focus_type *sd-plane-seltype* :select :selected_part partje :all_3d))) (setf vlag 0) (dolist (vlakje1 vlakjes "done") (sd-call-cmds (get_vol_prop :for_face vlakje1 :area) :success (setq opp *sd-action-result*) :failure (setq opp nil)) (if (equal opp nil) (setf opp 0.01) ()) (setf richting (sd-plane-normal (sd-inq-geo-props vlakje1 :dest-space :global))) (setf richting_x (gpnt3d_x richting)) (setf richting_y (gpnt3d_y richting)) (setf richting_z (gpnt3d_z richting)) (if (and (and (> (+ (abs richting_x) (+ (abs richting_y) (abs richting_z))) ondergrens) (< (+ (abs richting_x) (+ (abs richting_y) (abs richting_z))) bovengrens)) (> opp 1.0)) (progn (setf vlag 1) (GATHER_FACES :s_faces :new_p "/schevevlakken" :s_faces vlakje1 :split_body :off) (part_prop :the_part "/schevevlakken" :BASE_COLOR :color 16711680) ) () ) ) (if (equal vlag 0) (display "This part is OK!") () ) ) ) :ok-action '(doit) ) Jaap |
#5
|
||||
|
||||
Re: How to inquire the area of a face??
Glad to hear it works for you, and thanks for sharing the code!
Just a few notes on how the code could be improved even further. Note 1: Code:
(if some-condition (progn (do-this) (do-that)) ;; else ()) Code:
(when some-condition (do-this) (do-that)) Note 2: Your code creates several global variables on the fly ("richting_x", "richting_y", "richting_z", "vlag" etc.) which isn't good style, and is likely to cause subtle bugs at some point, in particular when using household words like "vflag" or "richting". (Well, OK, that would be Dutch households we're talking about, of course. ) Cheers, Claus
__________________
CoCreate Modeling FAQ: http://www.clausbrod.de/CoCreateModeling/ |
#6
|
||||
|
||||
Re: How to inquire the area of a face??
Hi Claus,
thanks for your comments! Always dangerous if guys like me (with only training in Fortran 25 years ago) start messing around with Lisp.... By the way, a collegue just tested the code, and found out that if multiple parts were selected, only one part was checked.... so I removed Code:
:multiple-items t Thinking about it, it would probably be nice to add the possibility to check an assembly. Kind regards, Jaap |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|