Villa007 Posted October 19, 2016 Share Posted October 19, 2016 hello all I am working for constraint on vba. But i am not able to code for constraints to change the value of it using vba. Suppose I have rectangle and one constraint is height d1 = 10 and other is width d2 = 15. I want to write code to change value for d1 using vba. Could someone help me. Thank you. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted October 19, 2016 Share Posted October 19, 2016 (edited) Compare two similar objects one with parametric the other plain. You you can see all the extra assoc codes. (entget (car (entsel))) Edited October 19, 2016 by BIGAL Quote Link to comment Share on other sites More sharing options...
Villa007 Posted October 19, 2016 Author Share Posted October 19, 2016 Thank you for replying. I am starting from the basics and this is my first time programming. Would you please tell me little bit more. Thanks Quote Link to comment Share on other sites More sharing options...
BIGAL Posted October 19, 2016 Share Posted October 19, 2016 This is a quicky and dirty example but it works, the right way would be to pick the object and find the parametric dims. The way to go is to make a defun that can be run many times with the variables to be changed say ("d1" "d4" "d5") ; example of changing constraint dim "d1" (defun c:test ( / ss obj) (setq ss (ssget '((0 . "dimension")))) ; pick all dims (repeat (setq x (sslength ss)) (setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1))))) (If (= (vla-get-DimConstrName obj) "d1") ; get the dim prefix need to know which one etc to change (vla-put-TextOverride obj (strcat "d1=" (getstring "Enter value "))) ; redo string etc with correct prefix ))) Quote Link to comment Share on other sites More sharing options...
BIGAL Posted October 20, 2016 Share Posted October 20, 2016 Thinking a bit more change it to a dynamic block so much easier to change values. 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.