Jump to content

Looking for vba sample to work on parameters


Recommended Posts

Posted

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.

Posted (edited)

Compare two similar objects one with parametric the other plain. You you can see all the extra assoc codes.

 

(entget (car (entsel)))

Edited by BIGAL
Posted

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

sample.jpg

Posted

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

Posted

Thinking a bit more change it to a dynamic block so much easier to change values.

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