Jump to content

Recommended Posts

Posted

After my terrible vocation in psyhiatric hospital i'm back asking questions

(vl-load-com)
(setq myFilter (list (cons 0 "LINE") (cons 410 "model")))
(setq alllines (ssget "x" myfilter))

(setq myFilter2 (list (cons 0 "insert") (cons 410 "model")))
(setq alllitems (ssget "x" myfilter2))

(setq acadobj1 (vlax-ename->vla-object (ssname alllines 0)))

(setq acadobj2 (vlax-ename->vla-object (ssname alllitems 0)))



(setq iPts (vla-intersectwith acadobj1 acadobj2 0))

(setq iPts (vlax-variant-value iPts))

(setq iPts (vlax-safearray->list iPts))

q3.jpg

Posted

dont remember where i found this lisp, however its says something like variant type is not good,i wonder why

 

(defun get_all_inters_in_SS (SS	/ SSL	;length of SS
		     PTS	;returning list
		     aObj1	;Object 1
		     aObj2	;Object 2
		     N1		;Loop counter
		     N2		;Loop counter
		     iPts	;intersects
)
 (setq	N1  0				;index for outer loop
SSL (sslength SS)
 )
				; Outer loop, first through second to last
 (while (< N1 (1- SSL))
				; Get object 1, convert to VLA object type
   (setq aObj1	(ssname SS N1)
  aObj1	(vlax-ename->vla-object aObj1)
  N2	(1+ N1)
   )					;index for inner loop
				; Inner loop, go through remaining objects
   (while (< N2 SSL)
				; Get object 2, convert to VLA object
     (setq aObj2 (ssname SS N2))
    aObj2 (vlax-ename->vla-object aObj2)
				; Find intersections of Objects
    iPts  (vla-intersectwith
	    aObj1
	    aObj2
	    0
	  )
				; variant result
    iPts  (vlax-variant-value iPts)
     )
				; Variant array has values?
     (if (> (vlax-safearray-get-u-bound iPts 1)
     0
  )
(progn				;array holds values, convert it
  (setq	iPts			;to a list.
	 (vlax-safearray->list iPts)
  )
				;Loop through list constructing points
  (while (> (length iPts) 0)
    (setq Pts  (cons (list (car iPts)
			   (cadr iPts)
			   (caddr iPts)
		     )
		     Pts
	       )
	  iPts (cdddr iPts)
    )
  )
)
     )
     (setq N2 (1+ N2))
   )					;inner loop end
   (setq N1 (1+ N1))
 					;outer loop end
 Pts
)					;return list of points found
(setq all (ssget "X"))
(get_all_inters_in_SS all)

q4.jpg

Posted

That "e" is used to represent very small, subunitary, coordinates:

(expt 10.0 -       ;will return 1.0e-008

(princ 0.00000001)   ;will return 1.0e-008

 

May also encounter it for big numbers:

(expt 10.0         ;will return 1.0e+008

Posted

On your first question, what you're seeing is the display value, it is in fact a double-precision floating-point number. It might "look" the same and probably they are but not really.

You have a misplaced closing parenthesis on the code you posted

(defun get_all_inters_in_SS (SS / SSL ;length of SS
       PTS ;returning list
       aObj1 ;Object 1
       aObj2 ;Object 2
       N1  ;Loop counter
       N2  ;Loop counter
       iPts ;intersects
)
 (setq N1  0    ;index for outer loop
SSL (sslength SS)
 )
    ; Outer loop, first through second to last
 (while (< N1 (1- SSL))
    ; Get object 1, convert to VLA object type
   (setq aObj1 (ssname SS N1)
  aObj1 (vlax-ename->vla-object aObj1)
  N2 (1+ N1)
   )     ;index for inner loop
    ; Inner loop, go through remaining objects
   (while (< N2 SSL)
    ; Get object 2, convert to VLA object
     (setq aObj2 (ssname SS N2)
       aObj2 (vlax-ename->vla-object aObj2)
    ; Find intersections of Objects
    iPts  (vla-intersectwith
     aObj1
     aObj2
     0
   )
    ; variant result
    iPts  (vlax-variant-value iPts))
    ; Variant array has values?
     (if (> (vlax-safearray-get-u-bound iPts 1)
     0
  )
(progn    ;array holds values, convert it
  (setq iPts   ;to a list.
  (vlax-safearray->list iPts)
  )
    ;Loop through list constructing points
  (while (> (length iPts) 0)
    (setq Pts  (cons (list (car iPts)
      (cadr iPts)
      (caddr iPts)
       )
       Pts
        )
   iPts (cdddr iPts)
    )
  )
)
     )
     (setq N2 (1+ N2))
   )     ;inner loop end
   (setq N1 (1+ N1))
       )
      ;outer loop end
 Pts
)     ;return list of points found
(setq all (ssget "X" ))
(get_all_inters_in_SS all)

 

HTH

Posted
z is 10000000 ?

 

switching to 2d workspace you think might help?

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