| Author |
Message |
Bob
Guest
|
Posted:
Fri Jan 07, 2005 2:47 am Post subject:
ActiveX - changing properties bug? |
|
|
I've been trying to get text alignment to change in the drawing after I
change it with ActiveX (see code below), I decided to try to force the text
to update by changing the text height to 1 and then back to the height that
I wanted (20). After I do this the text appears in the drawing as 20 unit
high but I can not longer select the text object by picking anywhere on the
text. Only at the insertion point (or anywhere the text at height of 1
would occupy). And the alignment is still left even though listing the
object shows it as center. Same result whether I 'update the txtobj or
'regen the activeviewport.
What is going on?
(setq ACADObject (vlax-get-acad-object)
ACADCollection (vlax-get-property ACADObject 'Documents)
NewDoc (vlax-invoke-method ACADCollection 'Add)
CModelSpace (vlax-get-property NewDoc 'ModelSpace)
LayerCollection (vlax-get-property NewDoc 'Layers)
testLayer (vlax-invoke-method LayerCollection 'add "testing")
);setq
(setq InPt (list 50 50 0)
TxtHt 20
TxtStr "Hello World!"
TxtObj (vlax-invoke-method CModelSpace 'addtext TxtStr
(vlax-3D-point InPt) TxtHt)
);setq
(vlax-put-property TxtObj 'alignment acAlignmentCenter)
(vlax-put-property TxtObj 'textalignmentpoint (vlax-3D-point InPt))
(vlax-put-property TxtObj 'alignment acAlignmentCenter)
(vlax-put-property TxtObj 'height 1)
(vlax-invoke-method NewDoc 'regen acactiveviewport)
(vlax-put-property TxtObj 'height txtht)
(vlax-invoke-method NewDoc 'regen acactiveviewport)
Dazed and confused!
|
|
| Back to top |
|
 |
Tony Tanzillo
Guest
|
Posted:
Fri Jan 07, 2005 3:49 am Post subject:
Re: ActiveX - changing properties bug? |
|
|
I'm pretty sure that the document you're working in
needs to be the Active document. Testing the same
code on text in the active document should confirm
that.
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005
http://www.acadxtabs.com
"Bob" <fraser@magma.ca> wrote in message news:41ddb1b9$1_1@newsprd01...
| Quote: | I've been trying to get text alignment to change in the drawing after I change it with ActiveX (see code below), I
decided to try to force the text to update by changing the text height to 1 and then back to the height that I wanted
(20). After I do this the text appears in the drawing as 20 unit high but I can not longer select the text object by
picking anywhere on the text. Only at the insertion point (or anywhere the text at height of 1 would occupy). And
the alignment is still left even though listing the object shows it as center. Same result whether I 'update the
txtobj or 'regen the activeviewport.
What is going on?
(setq ACADObject (vlax-get-acad-object)
ACADCollection (vlax-get-property ACADObject 'Documents)
NewDoc (vlax-invoke-method ACADCollection 'Add)
CModelSpace (vlax-get-property NewDoc 'ModelSpace)
LayerCollection (vlax-get-property NewDoc 'Layers)
testLayer (vlax-invoke-method LayerCollection 'add "testing")
);setq
(setq InPt (list 50 50 0)
TxtHt 20
TxtStr "Hello World!"
TxtObj (vlax-invoke-method CModelSpace 'addtext TxtStr (vlax-3D-point InPt) TxtHt)
);setq
(vlax-put-property TxtObj 'alignment acAlignmentCenter)
(vlax-put-property TxtObj 'textalignmentpoint (vlax-3D-point InPt))
(vlax-put-property TxtObj 'alignment acAlignmentCenter)
(vlax-put-property TxtObj 'height 1)
(vlax-invoke-method NewDoc 'regen acactiveviewport)
(vlax-put-property TxtObj 'height txtht)
(vlax-invoke-method NewDoc 'regen acactiveviewport)
Dazed and confused!
|
|
|
| Back to top |
|
 |
Alaspher
Guest
|
Posted:
Fri Jan 07, 2005 12:37 pm Post subject:
Re: ActiveX - changing properties bug? |
|
|
You should do vla-update for object like:
| Code: | (defun test (/ ACADCOLLECTION CMODELSPACE INPT
LAYERCOLLECTION NEWDOC TESTLAYER TXTHT
TXTOBJ TXTSTR
)
(setq ACADCollection (vla-get-Documents (vlax-get-acad-object))
NewDoc (vla-Add ACADCollection)
CModelSpace (vla-get-ModelSpace NewDoc)
LayerCollection (vla-get-Layers NewDoc)
testLayer (vla-add LayerCollection "testing")
InPt (vlax-3D-point (list 50 50 0))
TxtHt 20
TxtStr "Hello World!"
TxtObj (vla-addtext CModelSpace TxtStr InPt TxtHt)
)
(vla-put-alignment TxtObj acAlignmentCenter)
(vla-put-textalignmentpoint TxtObj InPt)
(vla-put-alignment TxtObj acAlignmentCenter)
(vla-put-height TxtObj 1)
(vla-put-height TxtObj txtht)
(vla-update TxtObj)
) |
best regards
|
|
| Back to top |
|
 |
Bob
Guest
|
Posted:
Fri Jan 07, 2005 1:19 pm Post subject:
Re: ActiveX - changing properties bug? |
|
|
Thanks for the feedback Alaspher.
I've tried both ways. Using vla and vlax. Using the code you posted here
still gives the same result. The text displays as default 'left' aligned
but when you list it's properties ACAD shows the alignment to be 'center'.
Just out of curiousity, what is the benefit of using vla over vlax? I'm
pretty new to all this.
Thanks again for the help.
"Alaspher" <nospam@address.withheld> wrote in message
news:21724242.1105083460884.JavaMail.jive@jiveforum1.autodesk.com...
| Quote: | You should do vla-update for object like:
| Code: | (defun test (/ ACADCOLLECTION CMODELSPACE
INPT
LAYERCOLLECTION NEWDOC TESTLAYER TXTHT
TXTOBJ TXTSTR
)
(setq ACADCollection (vla-get-Documents (vlax-get-acad-object))
NewDoc (vla-Add ACADCollection)
CModelSpace (vla-get-ModelSpace NewDoc)
LayerCollection (vla-get-Layers NewDoc)
testLayer (vla-add LayerCollection "testing")
InPt (vlax-3D-point (list 50 50 0))
TxtHt 20
TxtStr "Hello World!"
TxtObj (vla-addtext CModelSpace TxtStr InPt TxtHt)
)
(vla-put-alignment TxtObj acAlignmentCenter)
(vla-put-textalignmentpoint TxtObj InPt)
(vla-put-alignment TxtObj acAlignmentCenter)
(vla-put-height TxtObj 1)
(vla-put-height TxtObj txtht)
(vla-update TxtObj)
) |
best regards |
|
|
| Back to top |
|
 |
Alaspher
Guest
|
Posted:
Fri Jan 07, 2005 3:01 pm Post subject:
Re: ActiveX - changing properties bug? |
|
|
"Bob" wrote:
| Quote: | I've tried both ways. Using vla and vlax. Using the code you posted here
still gives the same result. The text displays as default 'left' aligned
but when you list it's properties ACAD shows the alignment to be 'center'.
|
If you want to put centred text in the valid position, then your code should be like this:
| Code: | (defun test (/ ACADCOLLECTION ALPT CMODELSPACE
INPT LAYERCOLLECTION MAXP MINP
NEWDOC TESTLAYER TXTHT TXTOBJ TXTSTR
)
(setq ACADCollection (vla-get-Documents (vlax-get-acad-object))
NewDoc (vla-Add ACADCollection)
CModelSpace (vla-get-ModelSpace NewDoc)
LayerCollection (vla-get-Layers NewDoc)
testLayer (vla-add LayerCollection "testing")
InPt (vlax-3D-point (list 50 50 0))
TxtHt 20
TxtStr "Hello World!"
TxtObj (vla-addtext CModelSpace TxtStr InPt TxtHt)
)
(vla-GetBoundingBox TxtObj 'MinP 'MaxP)
(setq MinP (vlax-safearray->list MinP)
MaxP (vlax-safearray->list MaxP)
AlPt (vlax-3D-point (list (/ (+ (car MinP) (car MaxP)) 2) (cadr MinP) (caddr MinP)))
)
(vla-put-alignment TxtObj acAlignmentCenter)
(vla-put-TextAlignmentPoint TxtObj AlPt)
(vla-move TxtObj AlPt InPt)
(vla-update TxtObj)
(princ)
) |
| Quote: | Just out of curiousity, what is the benefit of using vla over vlax?
I'm pretty new to all this.
|
vla-* is just easy for using (more readable) and vlax-* more universally, but in the simple code are redundant. In my opinion.
Best Regards |
|
| Back to top |
|
 |
|
|
|
|