Dim text override from within a block

Dim text override from within a block

Anonymous
Not applicable
952 Views
4 Replies
Message 1 of 5

Dim text override from within a block

Anonymous
Not applicable

Hi all,

 

I am working on a program that requires the text of a dimension to be overridden from within the block. The problem I'm facing is once the dim has the text overridden the change isn't viewable in the model or paper space. Once I open the block editor the change is shown. I have tried the vla-update, vla-regen methods with no avail. I have attached a shortened example code to show the issue at hand. Please let me know if you have any ideas for a possible solution.

 

Regards,

Mitch

 

P.S. I am running Mechanical 2017. Not sure if the Mechanical version is preventing the change.

(defun C:test1 (/ tmp)

	(setq tmp (getstring "name a block "))

	(vl-new-block tmp)

	(blk_rect_add tmp 0 0 3 4)

	(blk_dim_add tmp 2 1.5 2 -1.5 2)

)

(defun vl-new-block (name / blkColl insertionPnt)

    (setq
		blkColl (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-acad-object)))
		insertionPnt (vlax-3d-point 0 0 0)
	)
    (vla-Add blkColl insertionPnt name)
)

(defun blk_rect_add (blkin xcenter ycenter height width / acadObj points doc blk blkColl templ)

	(setq
		blkColl (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-acad-object)))
		l 0
		xlist (list + + - -)
		ylist (list + - - +)
		xd (* 0.5 width)
		yd (* 0.5 height)
		points (vlax-make-safearray vlax-vbDouble '(0 . 11))
	)
	
	(foreach
		point
		(mapcar '(lambda (x y) (list (x xcenter xd) (y ycenter yd) 0)) xlist ylist)
		(setq temp
			(if temp
				(append temp point)
				point
			)
		)
	)

	(vlax-safearray-fill points temp)
	(vla-put-Closed (vla-AddPolyline (vla-item blkColl blkin) points) :vlax-true)
)

(defun blk_dim_add (blkin p1x p1y p2x p2y loc / acadObj points doc blk blkColl l)

	(setq
		locx
			(if (= p1x p2x)
				(+ loc p1x)
				(* (+ p1x p2x) 0.5)
			)
		locy
			(if (= p1y p2y)
				(+ loc p1y)
				(* (+ p1y p2y) 0.5)
			)
		point1 (vlax-3D-point p1x p1y 0)
		point2 (vlax-3D-point p2x p2y 0)
		location (vlax-3D-point locx locy 0)
		blk (vla-item (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-acad-object))) blkin)
		Obj (vla-AddDimAligned blk point1 point2 location)
	)
	(vlax-put-property Obj "TextOverride" "CU TO CU\\N.063\\NTO\\N.057")
	(print (vlax-get-property Obj "TextOverride"))
)

 

 

0 Likes
953 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable

I haven't delved too far into your code, but from the symptoms you're describing this sounds like an attribute syncing issue. Have you tried using attsync on the block after changing the text?

0 Likes
Message 3 of 5

Anonymous
Not applicable

Hi @Anonymous ,

 

Thank you for the response. The problem I am dealing with isn't a block attribute but is a property of a vla-object held

within a block. The property is proved changed if you retrieve it's value through the database after the program has run and upon opening the block in the block editor. It is a very strange enigma.

 

regards,

Mitch

Message 4 of 5

jwhite
Advocate
Advocate

I know of 2 workarounds. You can open the block in the Block Editor and make your change there. When you close the editor and save the changes all existing references will be updated. You can also replace the existing block with the new reference. It will insert with the new definition but you have to match all of the properties of the existing reference. I typically make changes in the Block Editor. It's clumsy, but at least the changes are reflected in the previous references.

0 Likes
Message 5 of 5

Scottu2
Advocate
Advocate

Hello mitchellgilmore10,

 

I had a similar problem, changing the dimension text with existing overrides.  It would never update (dimupdate) to a different dimension style.  I had to use Dimoverride first.

Perhaps the routine could clear the overrides first, then apply new text override.

 

Scott

0 Likes