nkc_13 Posted April 21, 2019 Posted April 21, 2019 I have found the relevant lisp by Gruru Lee Mac, however, there is error msg "Region is not on the UCS plane: popped out for some object and I found that can be solved by converting the UCS as the object before creating the point at centroid of the polyline by the Lisp. May I ask is it possible to include the UCS command in the Lisp for each object? Greatly appreciate if any Master can help! (defun c:pc ( / acdoc acspc acsel reg ) (vl-load-com) ;; £ Lee Mac 2011 (setq acdoc (vla-get-ActiveDocument (vlax-get-acad-object)) acspc (vlax-get-property acdoc (if (= 1 (getvar 'CVPORT)) 'Paperspace 'Modelspace)) ) (if (ssget '((0 . "LWPOLYLINE") (-4 . "&=") (70 . 1))) (progn (vlax-for obj (setq acsel (vla-get-ActiveSelectionSet acdoc)) (vlax-invoke acspc 'addpoint (trans (vlax-get (setq reg (car (vlax-invoke acspc 'addregion (list obj)))) 'Centroid) 1 0) ) (vla-delete reg) ) (vla-delete acsel) ) ) (princ) ) Also I find the command for converting the UCS (defun c:obrotucs ( ) (command "ucs" "ob" pause "plan" "current") (princ) ) Quote
BIGAL Posted April 22, 2019 Posted April 22, 2019 (edited) The other way is to just work out the centroid from the vertice points, I think it was Gille that has a good one. Lee's code has a trans function that should handle the ucs function sure he will answer. Or ;; Polygon Centroid - Lee Mac ;; Returns the WCS Centroid of an LWPolyline Polygon Entity Edited April 22, 2019 by BIGAL Quote
Lee Mac Posted April 27, 2019 Posted April 27, 2019 Consider the following code: (defun c:pc ( / ent flg idx ocs reg sel spc ucs ) (if (setq sel (ssget '((0 . "LWPOLYLINE") (-4 . "&=") (70 . 1)))) (progn (setq ucs (trans '(0 0 1) 1 0 t) spc (vlax-get-property (vla-get-activedocument (vlax-get-acad-object)) (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace) ) ) (repeat (setq idx (sslength sel)) (if (setq idx (1- idx) ent (ssname sel idx) ocs (assoc 210 (entget ent)) flg (not (equal (cdr ocs) ucs 1e-8)) ) (vl-cmdf "_.ucs" "_ob" ent) ) (if (vl-catch-all-error-p (setq reg (vl-catch-all-apply 'vlax-invoke (list spc 'addregion (list (vlax-ename->vla-object ent))) ) ) ) (princ (strcat "\nError creating region: " (vl-catch-all-error-message reg))) (progn (entmake (list '(0 . "POINT") (cons 10 (trans (vlax-get (car reg) 'centroid) 1 0)) ocs)) (foreach obj reg (if (vlax-write-enabled-p obj) (vla-delete obj)) ) ) ) (if flg (vl-cmdf "_.ucs" "_p")) ) ) ) (princ) ) (vl-load-com) (princ) Quote
Wan Posted October 20, 2023 Posted October 20, 2023 (edited) Why the size of the circles got changed every time when the screen got zoomed in/out? Edited October 20, 2023 by Wan Quote
Steven P Posted October 20, 2023 Posted October 20, 2023 The centre of the polyline is marked by a point, I assume the circle is your point style? Use the command ptype to adjust the point style, your point can be relative (the size changes as you zoom) or absolute (it won't change, gets bigger or smaller as you zoom) - set it to absolute and it will stay the same 1 1 Quote
BIGAL Posted October 22, 2023 Posted October 22, 2023 I use pdmode all the time as just remember 1 number. 2 Quote
Recommended Posts
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.