changing block dimension overall scale

changing block dimension overall scale

dougwillmschen
Explorer Explorer
1,246 Views
7 Replies
Message 1 of 8

changing block dimension overall scale

dougwillmschen
Explorer
Explorer
Hi, i am hoping for some help. the code below allows a user to select a block the code than loops through
the block entities looking for dimensions when it finds one it changes the overall dimscale to 1.
that all seams to work fine. the problem is the block instance is not updated until i go into
the block editor.
entupd and regen do nothing.
(defun c:test () (Setq DimScale 1.0) (Setq Blk (car (entsel "Select Block"))) (Setq blockName (cdr (assoc 2 (entget blk)))) (setq ent (cdr (assoc -2 (tblsearch "block" blockName)))) ;;get the first ent in the block (while ent (if (= (cdr (assoc 0 elst)) "DIMENSION") (progn (Setq elst (entget ent '("ACAD"))) ;;Get the XData that contains the dimscale (Setq DimScaleDXF (assoc -3 elst)) (Setq CurDimScale (assoc 1040 (cdadr DimScaleDXF))) ;; Get the current dimscale (if (not (equal (cdr CurDimScale) DimScale 0.001)) (progn ;;If its not equal update it (Setq DimXdata (subst (cons 1040 DimScale) (assoc 1040 (cdadr DimScaleDXF)) (cdadr DimScaleDXF) ) ) (Setq DimXdata (append (list -3) (list (append (list "ACAD") DimXdata)) ) ) (Setq elst (subst DimXdata (assoc -3 elst) elst ) ) (entmod elst) (entupd ent) ;;For some reason this does not update the block (entupd Blk) ) ) ) ) (setq ent (entnext ent)) ) )

0 Likes
1,247 Views
7 Replies
Replies (7)
Message 2 of 8

dbhunia
Advisor
Advisor

@dougwillmschen wrote:
Hi, i am hoping for some help. the code below allows a user to select a block the code than loops through
the block entities looking for dimensions when it finds one it changes the overall dimscale to 1.
that all seams to work fine. the problem is the block instance is not updated until i go into
the block editor.
entupd and regen do nothing.
..................

 

I am little confuse about your requirement....... Do you want this....

 

 

(defun C:CDS ( / );;Put Temp Variables Here....
(setq CMD (getvar "CMDECHO"))
(setvar "CMDECHO" 0)
(setq dimsc (getreal "\nDimension scale factor inside Block: "))
(if (= (cdr (assoc 0 (entget (car (setq sel (entsel "Select a block: ")))))) "INSERT")
    (progn
	(command "_.-BEDIT" (cdr(assoc 2 (entget(car sel)))))
	(setq ss (ssget "_X" '((0 . "DIMENSION"))))
	  (repeat (setq N (sslength ss))
	     (setpropertyvalue (ssname ss (setq N (- N 1))) "Dimscale" dimsc)
	  )
	(command "_.BCLOSE")
	(while (> (getvar 'CMDACTIVE) 0)
	   (command "_save")
	)
    )
    (prompt "\nNo block selected")
)
(setvar "CMDECHO" CMD)
(princ)
)

Or you also talking about this matter.... (which is my question to Forum)....... because before today I never tried this....


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 Likes
Message 3 of 8

dougwillmschen
Explorer
Explorer
Thanks for your reply but i would like to avoid entering the block editor. i have multiple blocks to run this on and entering the block editor slows the code down alot.
the code that i provided modifies the dimension's dimscale without entering the block editor but for some reason the changes are not shown until i enter the block editor save and exit.
0 Likes
Message 4 of 8

dbhunia
Advisor
Advisor

Hi

 

If you prefer .net then check This...... you will get your solution......


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 Likes
Message 5 of 8

dougwillmschen
Explorer
Explorer

Thanks but i'd rather stick with lisp. looks like i need to find the lisp equivalent to 

dimen.RecomputeDimensionBlock(true);  
0 Likes
Message 6 of 8

dlanorh
Advisor
Advisor

@dougwillmschen wrote:
Hi, i am hoping for some help. the code below allows a user to select a block the code than loops through
the block entities looking for dimensions when it finds one it changes the overall dimscale to 1.
that all seams to work fine. the problem is the block instance is not updated until i go into
the block editor.
entupd and regen do nothing.
(defun c:test () (Setq DimScale 1.0) (Setq Blk (car (entsel "Select Block"))) (Setq blockName (cdr (assoc 2 (entget blk)))) (setq ent (cdr (assoc -2 (tblsearch "block" blockName)))) ;;get the first ent in the block (while ent (if (= (cdr (assoc 0 elst)) "DIMENSION") (progn (Setq elst (entget ent '("ACAD"))) ;;Get the XData that contains the dimscale (Setq DimScaleDXF (assoc -3 elst)) (Setq CurDimScale (assoc 1040 (cdadr DimScaleDXF))) ;; Get the current dimscale (if (not (equal (cdr CurDimScale) DimScale 0.001)) (progn ;;If its not equal update it (Setq DimXdata (subst (cons 1040 DimScale) (assoc 1040 (cdadr DimScaleDXF)) (cdadr DimScaleDXF) ) ) (Setq DimXdata (append (list -3) (list (append (list "ACAD") DimXdata)) ) ) (Setq elst (subst DimXdata (assoc -3 elst) elst ) ) (entmod elst) (entupd ent) ;;For some reason this does not update the block (entupd Blk) ) ) ) ) (setq ent (entnext ent)) ) )


The RED (if) statement is failing because "elst" is nil the first time through, thus nothing below it is processed.

When run in VLIDE "Blk" and "ent" are two different entities.

"Blk" is the block reference and "ent" is pointing to a line, and then cycles through entities but never finds a "DIMENSION".

I am not one of the robots you're looking for

0 Likes
Message 7 of 8

dlanorh
Advisor
Advisor
0 Likes
Message 8 of 8

dougwillmschen
Explorer
Explorer

Sorry but i am not sure why you gave me that link. the code i originally provided changes the dim scale already. the problem is that the change is not shown until i enter the block editor, save and exit.

the .net example you provided had an update function; i think that is what i need except as a lisp function.

 

0 Likes