Author Topic: Problem with vla-addobject  (Read 3697 times)

0 Members and 1 Guest are viewing this topic.

Coder

  • Swamp Rat
  • Posts: 827
Problem with vla-addobject
« on: June 28, 2013, 05:27:34 AM »
Hello guys.  :-)

I am facing a problem with the function vla-addobject with Autocad 2009 Operating System 64 that the two below ways don't work .

Code: [Select]
(vlax-invoke (vlax-ename->vla-object (cdr (assoc -1 (dictsearch (namedobjdict) "ACAD_MLEADERSTYLE"))))
  'addobject
  "Beams"
  "AcDbMLeaderStyle"
)

and not even this .

Code: [Select]
(vla-addobject (vlax-ename->vla-object (cdr (assoc -1 (dictsearch (namedobjdict) "ACAD_MLEADERSTYLE"))))
  "Beams"
  "AcDbMLeaderStyle"
)

Here is the error message .

Quote
; error: Automation Error. AcRxClassName entry is not in the system registry

Any help would be greatly appreciated .

Many thanks .
« Last Edit: June 28, 2013, 05:30:52 AM by Coder »

gile

  • Gator
  • Posts: 2520
  • Marseille, France
Re: Problem with vla-addobject
« Reply #1 on: June 28, 2013, 06:00:31 AM »
Hi,

IMO, working with dictionaries is much more easier with Vanilla AutoLISP.
Here's a little LISP library to deal with dictionaries (appologies for French comments)
Speaking English as a French Frog

Coder

  • Swamp Rat
  • Posts: 827
Re: Problem with vla-addobject
« Reply #2 on: June 28, 2013, 06:33:41 AM »
Thank you gile .

I can't follow your many examples  :embarrassed:

I need to know why my simple codes don't work or any solution .

Thank you .

Jeff_M

  • King Gator
  • Posts: 4099
  • C3D user & customizer
Re: Problem with vla-addobject
« Reply #3 on: June 28, 2013, 08:50:06 AM »
Coder, your examples work fine for me in 2009 on Win7x64. Can you run the MLEADER command in AutoCAD before trying to use your example? I'm thinking that an ARX or DLL must not be loaded. Does this portion of the code return a valid VLA-OBJECT? (vlax-ename->vla-object (cdr (assoc -1 (dictsearch (namedobjdict) "ACAD_MLEADERSTYLE"))))

Coder

  • Swamp Rat
  • Posts: 827
Re: Problem with vla-addobject
« Reply #4 on: June 28, 2013, 10:49:59 AM »
Coder, your examples work fine for me in 2009 on Win7x64. Can you run the MLEADER command in AutoCAD before trying to use your example?

Thank you so much for your try Jeff  :-)

Yes I can use the mleader in my cad version 2009 and everything is fine with the command .

I'm thinking that an ARX or DLL must not be loaded. Does this portion of the code return a valid VLA-OBJECT? (vlax-ename->vla-object (cdr (assoc -1 (dictsearch (namedobjdict) "ACAD_MLEADERSTYLE"))))

Yes it does return a valid VLA-OBJECT and this is what it returns .

#<VLA-OBJECT IAcadDictionary 00000000282eb4d8>

Hope you can help me with this problem . :-)

Many thanks

BlackBox

  • King Gator
  • Posts: 3770
Re: Problem with vla-addobject
« Reply #5 on: June 28, 2013, 11:58:45 AM »
... it does return a valid VLA-OBJECT and this is what it returns .

#<VLA-OBJECT IAcadDictionary 00000000282eb4d8>

Hope you can help me with this problem . :-)

That isn't a problem, it's the resultant 'Beam' Multileader Style Object you just created :wink: :

Code - Auto/Visual Lisp: [Select]
  1. Command: (setq foo (vlax-invoke (vlax-ename->vla-object (cdr (assoc -1
  2. (dictsearch (namedobjdict) "ACAD_MLEADERSTYLE"))))
  3. ((_>   'addobject
  4. ((_>   "Beams"
  5. ((_>   "AcDbMLeaderStyle"
  6. ((_> ))
  7. #<VLA-OBJECT IAcadMLeaderStyle 0000000050ed5178>
  8.  
  9. Command: !foo
  10. #<VLA-OBJECT IAcadMLeaderStyle 0000000050ed5178>
  11.  
  12. Command: (_dump foo)
  13. ; IAcadMLeaderStyle: AutoCAD MLeaderStyle Interface
  14. ; Property values:
  15. ;   AlignSpace = 5.0
  16. ;   Annotative = 0
  17. ;   Application (RO) = #<VLA-OBJECT IAcadApplication 0000000140d8ced8>
  18. ;   ArrowSize = 0.18
  19. ;   ArrowSymbol = ""
  20. ;   BitFlags = -2020184400
  21. ;   Block = ""
  22. ;   BlockColor = #<VLA-OBJECT IAcadAcCmColor 00000000bb725810>
  23. ;   BlockConnectionType = 0
  24. ;   BlockRotation = 0.0
  25. ;   BlockScale = 1.0
  26. ;   BreakSize = 0.125
  27. ;   ContentType = 2
  28. ;   Description = ""
  29. ;   Document (RO) = #<VLA-OBJECT IAcadDocument 000000007cda21d0>
  30. ;   DoglegLength = 2.0
  31. ;   DrawLeaderOrderType = 0
  32. ;   DrawMLeaderOrderType = 1
  33. ;   EnableBlockRotation = -1
  34. ;   EnableBlockScale = -1
  35. ;   EnableDogleg = -1
  36. ;   EnableFrameText = 0
  37. ;   EnableLanding = -1
  38. ;   FirstSegmentAngleConstraint = 0
  39. ;   Handle (RO) = "998B"
  40. ;   HasExtensionDictionary (RO) = 0
  41. ;   LandingGap = 0.4
  42. ;   LeaderLineColor = #<VLA-OBJECT IAcadAcCmColor 00000000bb7256f0>
  43. ;   LeaderLinetype = 1
  44. ;   LeaderLineTypeId = AutoCAD.Application: Null object ID
  45. ;   LeaderLineWeight = -2
  46. ;   MaxLeaderSegmentsPoints = 2
  47. ;   Name = "Beams"
  48. ;   ObjectID (RO) = 223931
  49. ;   ObjectID32 (RO) = 223931
  50. ;   ObjectName (RO) = "AcDbMLeaderStyle"
  51. ;   OverwritePropChanged (RO) = 0
  52. ;   OwnerID (RO) = 223932
  53. ;   OwnerID32 (RO) = 223932
  54. ;   ScaleFactor = 1.0
  55. ;   SecondSegmentAngleConstraint = 0
  56. ;   TextAlignmentType = 0
  57. ;   TextAngleType = 0
  58. ;   TextAttachmentDirection = 0
  59. ;   TextBottomAttachmentType = 0
  60. ;   TextColor = #<VLA-OBJECT IAcadAcCmColor 00000000bb725210>
  61. ;   TextHeight = 0.2
  62. ;   TextLeftAttachmentType = 2
  63. ;   TextRightAttachmentType = 3
  64. ;   TextString = ""
  65. ;   TextStyle = AutoCAD.Application: Null object ID
  66. ;   TextTopAttachmentType = 0
  67. ; Methods supported:
  68. ;   Delete ()
  69. ;   GetExtensionDictionary ()
  70. ;   GetXData (3)
  71. ;   SetXData (2)
  72.  

BTW - All works well for me as well, Land Desktop 2009, Win7-64bit... Without first running any MLeader Command.
"How we think determines what we do, and what we do determines what we get."

Coder

  • Swamp Rat
  • Posts: 827
Re: Problem with vla-addobject
« Reply #6 on: June 28, 2013, 12:34:28 PM »
... it does return a valid VLA-OBJECT and this is what it returns .

#<VLA-OBJECT IAcadDictionary 00000000282eb4d8>

Hope you can help me with this problem . :-)

That isn't a problem, it's the resultant 'Beam' Multileader Style Object you just created :wink: :

BTW - All works well for me as well, Land Desktop 2009, Win7-64bit... Without first running any MLeader Command.

Thanks for testing the code BlackBox .  :-)

What is the meaning of the return error that I included in my first post then ?

Man thanks .

BlackBox

  • King Gator
  • Posts: 3770
Re: Problem with vla-addobject
« Reply #7 on: June 28, 2013, 12:44:20 PM »
Thanks for testing the code BlackBox .  :-)

You're welcome.

What is the meaning of the return error that I included in my first post then ?

Not sure... Is this still an error you're receiving? Your last post stated that you're now able to return a valid Object, no?
"How we think determines what we do, and what we do determines what we get."

Jeff_M

  • King Gator
  • Posts: 4099
  • C3D user & customizer
Re: Problem with vla-addobject
« Reply #8 on: June 28, 2013, 03:20:35 PM »
What is the meaning of the return error that I included in my first post then ?
Not sure... Is this still an error you're receiving? Your last post stated that you're now able to return a valid Object, no?
The valid object returned was the Dictionary obtained with the (vlax-ename->vla-object ....) section of the code. Coder's code seems to be failing with the AddObject method, although I have no idea why, as it seems to work fine for both of us.