CoCreate User Forum  

Go Back   CoCreate User Forum > Support > Customization
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 01-31-2008, 06:38 AM
jkramer's Avatar
jkramer jkramer is offline
Registered User
 
Join Date: Oct 2002
Location: the Netherlands
Posts: 382
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)
But it returns value NIL all the time
I've searched the help file, but haven't found any alternative; does anyone have a clue??
Thanks!
Regards,
Jaap
Reply With Quote
  #2  
Old 01-31-2008, 07:14 AM
clausb's Avatar
clausb clausb is offline
Registered User
 
Join Date: Nov 2002
Posts: 1,168
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/
Reply With Quote
  #3  
Old 01-31-2008, 07:46 AM
Andy Poulsen Andy Poulsen is offline
Administrator
 
Join Date: Apr 2003
Location: Fort Collins, Colorado
Posts: 273
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 believe that will do what you want. Note: you'll want to replace "myresult" in the above code with the variable you want to set, of course...

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!
Reply With Quote
  #4  
Old 02-01-2008, 12:52 AM
jkramer's Avatar
jkramer jkramer is offline
Registered User
 
Join Date: Oct 2002
Location: the Netherlands
Posts: 382
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)
)
Kind regards,
Jaap
Reply With Quote
  #5  
Old 02-01-2008, 01:08 AM
clausb's Avatar
clausb clausb is offline
Registered User
 
Join Date: Nov 2002
Posts: 1,168
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
     ())
is equivalent to

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/
Reply With Quote
  #6  
Old 02-01-2008, 01:21 AM
jkramer's Avatar
jkramer jkramer is offline
Registered User
 
Join Date: Oct 2002
Location: the Netherlands
Posts: 382
Thumbs up 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
from the "partje-line" for now.
Thinking about it, it would probably be nice to add the possibility to check an assembly.

Kind regards,
Jaap
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 02:47 PM.



Hosted by SureServer    Forums   Modeling FAQ   Macro Site   Vendor/Contractors   Software Resellers   CoCreate   Gallery   Home   Board Members   Regional User Groups  By-Laws  

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.