Jump to content

Recommended Posts

Posted

Hi all

 

Got a problem with a lisp which basically reads an angle. i have the value of the said angle held in a variable (converted to deg) called for arguments sake ANGLE1. when i input (ANGLE1) at the command line it shows as 30.0 which is correct but then if i input (= ANGLE1 30.0) it should return T but for some reason it returns nil.

 

If i type (setq ANGLE1 30.0) then repeat the (= ANGLE1 30.0) it does return T

 

Does anyone know why the variable ANGLE1 stored from the actual angle doesn't work?

 

 

I have simplified the actual program so it easier to explain, hope it reads correctly.

Posted

the original ANGLE1 variable is taken from an angle between 2 (getpoints)

 

if you use (setq ANGLE1 (getangle "\nPick Angle")) then pick angle (polar 30 degrees) which should return 0.523599 radians

 

then use (setq ANGLE2 (* (/ ANGLE1 pi) 180)) which returns 30.0

then try (= ANGLE2 30.0) which returns nil

Posted

Expression (/ ANGLE1 pi) is continued fraction 1.6666666.... and can't be calculate with absolute precision. For operations with real numbers use function EQUAL with fuzz, insted '='.

 

Command :(equal ANGLE2 30.0 0.000000000001)

T

Posted

Thank you for your time guys. Using (equal ANGLE2 30.0 0.000000000001) worked perfectly. thank you for that ASMI.

  • 5 years later...
Posted

I am trying to take two the angles from a dynamic block. Then alter the angles by a given amount and feed the angles back into the dynamic block. I realize some of my code is redundant and can be cleaned up but I am using it to troubleshoot.

 

I think the issue is with feeding the angle back into the bock. It might have to be in a different format.

 

I adapted this code from some existing code my company was already using for changing a length variable of a dynamic block. (That part works!)

 

Also I realize there may be some components missing.

 

;Adjust Bracing Block by Increments
(defun C:ISATBRACEBUMP()
(vl-load-com)
(if (= (vl-registry-read "HKEY_CURRENT_USER\\Datum" "Datum-Elev") nil)
	(progn
		(princ "\n== SET DATUM ELEVATION FIRST ==\n")
	)
	(progn
		(setq RX (ssget '((0 . "INSERT"))))	
		(setq LE_RX (sslength RX))
		(setq A 0)
		(repeat LE_RX
			(setq ANGMODAMT 5) ; this will be ajustable later.
			(setq ANGBRACES (SSNAME RX A))	
			(setq oBkRef (vlax-ename->vla-object ANGBRACES))
			(setq SEIS_ANG_R_1 (getdynpropvalue OBkRef "Angle")) 
			(setq SEIS_ANG_D_1 (RTD SEIS_ANG_R_1)) 
			(setq SEIS_ANG_R_2 (getdynpropvalue OBkRef "Angle1")) 
			(setq SEIS_ANG_D_2 (RTD SEIS_ANG_R_2)) 
			(setq SEIS_ANG_D_1_M (+ SEIS_ANG_D_1 ANGMODAMT))
			(setq SEIS_ANG_D_2_M (+ SEIS_ANG_D_2 ANGMODAMT))
			(setq SEIS_ANG_R_1_M (DTR SEIS_ANG_D_1_M)) 
			(setq SEIS_ANG_R_2_M (DTR SEIS_ANG_D_2_M)) 
			(princ SEIS_ANG_R_1_M)
			(princ SEIS_ANG_R_2_M)
			(chgdynprop oBkRef "Angle" getangl(SEIS_ANG_R_1_M))
			(chgdynprop oBkRef "Angle1" SEIS_ANG_R_2_M)
			(princ)
			
			(SETQ A (+ A 1))
		)
		
	)
)
)

;DUPLICATE TEXT - TO BE REMOVED WHEN INCORPORATED INTO MASTER TEXT

(defun dtr (a)
(* pi (/ a 180.0))
)

(DEFUN RTD (A)
(/ (* A 180.0) PI)
)

(defun getdynprops (obj / v)
 (mapcar '(lambda (x)
             (if (setq v (vlax-variant-value (vla-get-value x)))
             (cons (vla-get-propertyname x) v)))
  (vlax-invoke obj 'getdynamicblockproperties)
  )
);defun http://www.theswamp.org/index.php?topic=22663.0

(defun getdynpropvalue (obj name / v)
 (cdr (assoc name
     (mapcar '(lambda (x)
               (if (setq v (vlax-variant-value (vla-get-value x)))
               (cons (vla-get-propertyname x) v)))
     (vlax-invoke obj 'getdynamicblockproperties))))  
);defun 

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