aridzv Posted January 2, 2022 Share Posted January 2, 2022 (edited) Hi. I have a lisp (see attched) that rotate and set the length of a prametric block. I can't find a way to get the block attribute to rotate along with it.... I've looked for a tutorial but all I find is multiple blocks and attribute rotation using loops and I can't figure it out... I need help with a rutine that set the attribute rotation in a block already selected and to a known value that is also known with in the lisp. if it possible, I need help with rotating just one attribute - "QUANTITY" for example, so I will learn the basics first. as it shown in the lisp,the block is already selected (obj), and the angle is also calculated and inserted in to a variable (ang). thanks, Ari. (defun c:PipeLenBL (/ obj p1 di X Y insut ) (setq obj (car (entsel "\nSelect Block "))) (setq p1 (getpoint "\nPoint 1: ")) (setq p2 (getpoint "\nDistance: ")) (setq di (distance p1 p2)) (setpropertyvalue obj "d1" (rtos di 2 10)) (setq insut (getvar "insunits")) ( if (= insut 4) (setpropertyvalue obj "QUANTITY" (rtos (* di 0.001) 2 3)) ) ( if (= insut 6) (setpropertyvalue obj "QUANTITY" (rtos di 2 3)) ) (setq ang (angle p1 p2)) (setq X (getpropertyvalue obj "ScaleX")) (setq Y (getpropertyvalue obj "ScaleY")) ( if (< (+ X Y) 1) (setq ang (angle p2 p1)) ) (setpropertyvalue obj "Rotation" ang) (princ) ) Edited January 2, 2022 by aridzv Quote Link to comment Share on other sites More sharing options...
mhupp Posted January 2, 2022 Share Posted January 2, 2022 Can you attach the block? Quote Link to comment Share on other sites More sharing options...
aridzv Posted January 3, 2022 Author Share Posted January 3, 2022 (edited) 15 hours ago, mhupp said: Can you attach the block? Yes, of course. I've attached 2 files: 1. PVC PIPE DN63 PN10 ID-56 GRAY_DY1.dwg - the block it self. 2. Drawing1.dwg - a drawing that the block is inserted in to it. Thanks! *EDIT: I found a way to do it with loop after Having read this excellent explanation By Lee MAC in this topic. to keep it simple I have decided to change all the attributes rotation in this case instand of doing "if" statment to "Fish" just the "QUANTITY" attribute, but still,is there a way to get to the specipic attribute with out creating a collection and then looping? (setq obj (entlast)) ;selecting the block object (setq obj1 (vlax-ename->vla-object obj)) ;converting the selected object to a vlax object . . . (foreach att (vlax-invoke Obj1 'GetAttributes) ;getting the block attributes in to a list/collection (vla-put-Rotation att ang) ;and looping through the block attributes and change the rotation ) Drawing1.dwg PVC PIPE DN63 PN10 ID-56 GRAY_DY1.dwg Edited January 3, 2022 by aridzv Quote Link to comment Share on other sites More sharing options...
mhupp Posted January 3, 2022 Share Posted January 3, 2022 setpropertyvalue only works on set properties of the object. use this on your block to see the properties. ;;----------------------------------------------------------------------------;; ;; Dump all methods and properties for selected objects (defun C:DumpIt (/ ent) (if (setq SS (ssget)) (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))) (vlax-Dump-Object (vlax-Ename->Vla-Object ent) t) ) ) (textscr) (princ) ) Dynamic blocks can't be made by BricsCAD only edited. Thats why they came up with Parametric blocks. If constrained properly their should be a section in the properties window (Ctrl + 1) shown here. The parametric dimensions Are not attributes or dynamic so i don't know what to set. I don't really use this type of block so maybe someone else can chime in. Quote Link to comment Share on other sites More sharing options...
aridzv Posted January 3, 2022 Author Share Posted January 3, 2022 (edited) 7 hours ago, mhupp said: setpropertyvalue only works on set properties of the object. use this on your block to see the properties. Dynamic blocks can't be made by BricsCAD only edited. Thats why they came up with Parametric blocks. If constrained properly their should be a section in the properties window (Ctrl + 1) shown here. The parametric dimensions Are not attributes or dynamic so i don't know what to set. I don't really use this type of block so maybe someone else can chime in. Hi. Actualy (for all of us,the Bricscad users... ), there is no problem to get to the parametric dimensions and set them as long as they are set as visible in the parametric block itself, see in my LSP: (setpropertyvalue obj "d1" (rtos di 2 10)). d1 is a visible parameter constraint for example. the rest of the properties and attributes are the same as in Autocad. Edited January 3, 2022 by aridzv Quote Link to comment Share on other sites More sharing options...
mhupp Posted January 3, 2022 Share Posted January 3, 2022 1 hour ago, aridzv said: as long as they are set as visible in the parametric block itself Ah I had set them to hidden. like I said don't really use parametric blocks. I know they have updated alot since iv gotten BricsCAD. but that command still isn't working for me. ; error : no function definition <SETPROPERTYVALUE> ; expected FUNCTION at [eval] Quote is there a way to get to the specific attribute with out creating a collection and then looping? Not really you have to loop though them to get the one you want. (foreach att (vlax-invoke Obj1 'GetAttributes) ;getting the block attributes in to a list/collection (if (eq att "QUANTITY") (vla-put-Rotation att ang) ;rotates quantity att ) ) Quote Link to comment Share on other sites More sharing options...
aridzv Posted January 3, 2022 Author Share Posted January 3, 2022 (edited) 29 minutes ago, mhupp said: Ah I had set them to hidden. like I said don't really use parametric blocks. I know they have updated alot since iv gotten BricsCAD. but that command still isn't working for me. ; error : no function definition <SETPROPERTYVALUE> ; expected FUNCTION at [eval] O.K... Maybe because the loop that rotate the attributes use VLA object. in my code I assign the regular object to a VLA object just for the use of the attribute rotation,like this: (setq obj (entlast)) ;; Get the pipe object (setq obj1 (vlax-ename->vla-object obj)) ;; set the pipe object to a VLA object for the attribute rotation function and use obj1 in the attribute rotation function. I also attched the full lsp file so you can check it out if you want. 29 minutes ago, mhupp said: Not really you have to loop though them to get the one you want. (foreach att (vlax-invoke Obj1 'GetAttributes) ;getting the block attributes in to a list/collection (if (eq att "QUANTITY") (vla-put-Rotation att ang) ;rotates quantity att ) ) Thanks For That!! Ari. PipeLenBL.lsp Edited January 3, 2022 by aridzv 1 Quote Link to comment Share on other sites More sharing options...
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.