Jump to content

Recommended Posts

Posted

Good day.

I'm trying to do an operation on many 3DFACEs. I need to change vertex like this:

before:

V1: x1=5.12345678 y1=3.23456789 z1=7.42345678

after:

V1: x1=5.12000000 y1=3.23000000 z1=7.42000000

 

(defun c:zz ()
(vl-load-com)
(if (setq ssSelections (ssget (list (cons 0 "3DFACE"))))
(repeat (setq intCount (sslength ssSelections))
 (setq intCount     (1- intCount)
       entSelection (ssname ssSelections intCount)
       lstEntity    (entget entSelection)
       objSelection (vlax-ename->vla-object entSelection)
 )
 		;Vertex 1
	(setq wierzcholek1 (assoc 10 lstEntity))
		(setq x1 (nth 1 wierzcholek1))
		(setq y1 (nth 2 wierzcholek1))
		(setq z1 (nth 3 wierzcholek1))
	;Vertex 2
		(setq wierzcholek2 (assoc 11 lstEntity))
		(setq x2 (nth 1 wierzcholek2))
		(setq y2 (nth 2 wierzcholek2))
		(setq z2 (nth 3 wierzcholek2))
;.....
;change point
(setq nowaDef (subst (cons 10 (list		(atof (rtos x1 2 2))
									(atof (rtos y1 2 2))
									(atof (rtos z1 2 2))
														) (assoc '10 lstEntity ) lstEntity ) ))
(setq nowaDef (append lstEntity (list (cons 10 (list 	(atof (rtos x1 2 2))
													(atof (rtos y1 2 2))
													(atof (rtos z1 2 2)))) ) ) )
(entmod nowaDef)
;podmiana punktu 2
(setq nowaDef (subst (cons 11 (list 	(atof (rtos x2 2 2))
									(atof (rtos y2 2 2))
									(atof (rtos z2 2 2))
														) (assoc '11 lstEntity ) lstEntity ) ))
(setq nowaDef (append lstEntity (list (cons 11 (list 	(atof (rtos x2 2 2))
													(atof (rtos y2 2 2))
													(atof (rtos z2 2 2)))) ) ) )
(entmod nowaDef)
);end repeat
);end if
(print)
);END

 

Could anyone tell me what i'm doing wrong?

Posted

Hi there!

 

First of all, you have a misplaced parenthesis at 2 places in your code

it should be

(setq nowaDef (subst (cons 10
		   (list (atof (rtos x1 2 2))
			 (atof (rtos y1 2 2))
			 (atof (rtos z1 2 2))
		   )
	     )
	     (assoc '10 lstEntity)
	     lstEntity
      )
)

Right after that if you entmod it, the result is shown.. BUT after that when you iterate for the 2nd vertex, you start with lstentity variable, which contain points before the first entmod, so you revert them back.

Without knowing exactly what you are after, let'S just say that I don't get what you are trying to achieve with the part when you append.

-retrieve list entity

-subst all the things you need

-THEN entmod.

 

more calls to entmod are useless, and you would need to use the entmoded list instead of the original one.

 

Cheers

Posted

An alternative to rtos and atof I would make it a tiny defun (2dec X)

 

123.4567*100

fix 12345.67

/100

=123.45

 

Not sure which is faster on a big data set.

 

(defun 2dec ( x / )
(/ (fix (* x 100.)) 100.0)
)
; to use 
; (setq x2 (2dec x2))
; or
;(list  (2dec x) (2dec y) (2dec z))

 

Have a look at this as well may be usefull

 

(setq obj (vlax-ename->vla-object (car (entsel "\nPick 3dface"))))
(setq pointls (vlax-safearray->list (vlax-variant-value (vla-get-Coordinates obj))) )

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