Jump to content

dynamic insert of a dynamic block.


Huibert

Recommended Posts

I have created a dynamic block. with several actions.

- Especially one stretch action depending on a linear parameter "DIAMETER" which is show as a proporty "DIAMETER" in the proporties list of the inserted block

- And a visibility parameter that defines the side of view.

 

I want to put this block in a kind of library pulldown menu where there are several options to import the same block, but with the correct view (the right visibility), and the correct "DIAMETER". This means that it will only require 1 click in the pulldown menu, and of course the right insertion point and angle in the drawing.

 

I have a library support file that now reads (only one line):

 

**Sparingbuis

[sparingsbuis]

[sparingsbuis]^C^C-insert;"2280_M8=z:/standaard documenten/autocad/Bibliotheek/Sparingsbuis.dwg" ^P\1;1;

 

This will import the dynamic block as i defined it in the block editor. this works perfect. But i want to have:

 

**Sparingbuis

[sparingsbuis]

[sparingsbuis_33/39_zijaanzicht]^C^C-insert;"2280_M8=z:/standaard documenten/autocad/Bibliotheek/Sparingsbuis.dwg" ^P\1;1;

+ -select the proporty "Diameter: 39" and visablity: "zijaanzicht"-

or something that does something like that.

 

but i have no clue how to create a posibility import these proporties without having to click on the dynamic block grip points.

 

Can anyone give me an advise on where to look for the solution?

 

Huibert

Link to comment
Share on other sites

I would like to have that VBA code to insert the dynamic block according to certain specifications. That would be of great help.

Link to comment
Share on other sites

  • 1 year later...
I have a piece of VBA code that does what you want, let me look for that

 

Hi there all,

 

We have a series of dynamic blocks with some parameters we wish to be able to control upon insertion. i.e. - we have a variable structural column block we would like to specify size upon insertion.

 

Does anyone know of a way to control this on insertion or is this only possible after insertion?

 

Regards,

 

John

Link to comment
Share on other sites

John,

 

To set the parameters of the dynamic block you can use this:

(defun PushDBProps (objent lst / blkprops propname propvalue n )
;; (PushDBProps ename|object '(("Visibility" . "No Shelves")("Width" . 36.0)...))
;; objent: ename or object of dynamicblock (vlax-ename->vla-object (car (entsel)))
;; lst: list of dotted pairs '((propname1 . newvalue1)(propname2 . newvalue2)...)
(if (= 'ENAME (type objent))(setq objent (vlax-ename->vla-object objent)))
(setq blkprops
 (vlax-safearray->list
  (vlax-variant-value (vla-getdynamicblockproperties objent))
 )
)
(foreach prop lst
 (setq n 0)
 (setq propname (car prop))
 (setq propvalue (cdr prop))
 (while (< n (length blkprops))
  (if (= propname (vlax-get-property (nth n blkprops) "PropertyName"))
   (progn
    (vlax-put-property (nth n blkprops) "Value" propvalue)
    (setq n (length blkprops))
   )
   (setq n (1+ n))
  )
 )
)
)

 

You're right that it's only possible to control the parameters after insertion, but you can use a trick: Insert the dynamic block and change the parameters. Then create a temprary block of the new objects and explode this temporary block after it's been inserted:

(defun DB-insert (blocknaam bscale LAAG OSMODE GROOTTE HOEK DBprops
    / *error* lay OM DM BM bscale temp ip Gb-varlist Gb-temperr blok)
; blocknaam BLOCKNAME
; bscale        BLOCKSCALE
; LAAG  Layer for new block - nil=use current layer
; OSMODE OSMODE used while inserting the block - nil=use active osmode
; HOEK  T=use angle of UCS - nil=user input for angle
; DBprops Properties-list voor 'dynamic block'
; errorroutine: *************************************************************************************************
(setq Gb-varList '("CLAYER" "OSMODE" "DYNMODE" "BLIPMODE")
 Gb-varList (mapcar (function (lambda (a) (list 'setvar a (getvar a)))) Gb-varList)
 Gb-temperr *error*)
(defun *error* (msg)
 (prompt (strcat "\nError: " msg))
 (mapcar 'eval Gb-varList)
 (setq *error* Gb-temperr)
 (princ)
)
(if (not (tblsearch "BLOCK" blocknaam))
 (if (not (findfile (strcat blocknaam ".dwg")))
  (progn
   (alert (strcat "The block " blocknaam " is not found!"))
   (exit)
  )
 )
)

; Mainroutine: **************************************************************************************************
(setvar "OSMODE" 0)(setvar "BLIPMODE" 0)
(setq ip (getvar "VIEWCTR"))
(if HOEK
 (command ".-insert" blocknaam ip bscale bscale HOEK)
 (command ".-insert" blocknaam ip bscale bscale 0)
)
(while (= (getvar "CMDACTIVE") 1)(command "")); accept default-values of attributes
(command ".chprop" (entlast) "" "LA" (getvar "CLAYER") "")
(PushDBProps (entlast) DBprops)
(if (tblsearch "BLOCK" "Gb-temp")
 (command ".-block" "Gb-temp" "yes" ip (entlast) "")
 (command ".-block" "Gb-temp" ip (entlast) "")
)
(setvar "DYNMODE" 3)(setvar "BLIPMODE" BM)(if OSMODE (setvar "OSMODE" OSMODE)(setvar "OSMODE" OM))
; This corrects a strange bug that happens sometimes (the insertionpoint has moved!?):
(setq blok (entget (cdr (assoc -2 (tblsearch "BLOCK" "Gb-temp")))))
(setq blok (subst '(10 0.0 0.0 0.0)(assoc 10 blok) blok))
(entmod blok)
(if HOEK
 (command ".-insert" "Gb-temp" pause 1. 1. 0)
 (command ".-insert" "Gb-temp" pause 1. 1. pause)
)
(command ".explode" (entlast))
; ; Attributes?
(setq att (entlast))
(if (assoc 66 (entget att))(progn
 (command ".attsync" "Select" (entlast) "Y")
 (command "._ddatte" att)
))
; reset variabels and error-routine: ****************************************************************************
(mapcar 'eval Gb-varList)
(setq *error* Gb-temperr)
(princ)
)

Link to comment
Share on other sites

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