Author Topic: LDD3 and preferences  (Read 3659 times)

0 Members and 1 Guest are viewing this topic.

Jeff_M

  • King Gator
  • Posts: 4040
  • C3D user & customizer
LDD3 and preferences
« on: June 10, 2004, 07:31:33 PM »
I'm trying to finish a little lisp that re-inserts the existing ground for the current profile. Everything works except for placing the new pline onto the correct layer. The actual placing of it won't be a problem, if I could only get what the layer is supposed to be.....

In VBA I can use this (tested OK):
Debug.Print proj.Preferences.profile.GetString(kEGCLayer)

However, I have tried what seems like a thousand different combinations of getting this data in lisp with no luck whatsoever. Can anyone point me in the right direction?

   (setq prefs (vlax-get aecproj "Preferences"))
   (setq proPref (vlax-get prefs "profile"))

Here's what I've tried, with aecproj being a valid project:
   (setq prolay (vlax-invoke-method proPref 'GetString 'kegclayer))
&
   (setq prolay (vlax-invoke proPref "GetString" 'kegclayer))
&
   (setq prolay (vlax-invoke proPref "GetString" 3))
&
   (setq prolay (vlax-invoke proPref "GetString" "kegclayer"))
&
   (setq prolay (vlax-invoke proPref "GetString" kegclayer))
&
others, but you get the idea.....

Also, here's another case of the Help file having incorrect information...it says the konstant name is kEGLayer, where the intellisense in VBA correctly show it as kEGCLayer.

Thanks, Jeff

Mark

  • Custom Title
  • Seagull
  • Posts: 28725
LDD3 and preferences
« Reply #1 on: June 10, 2004, 08:13:31 PM »
I can't say for sure at this minute (I'm in unix) but I believe you want the preferences object from the dwg, not the project. I seem to remember the two pref's are different objects.
TheSwamp.org  (serving the CAD community since 2003)

Jeff_M

  • King Gator
  • Posts: 4040
  • C3D user & customizer
LDD3 and preferences
« Reply #2 on: June 10, 2004, 08:44:43 PM »
Hi Mark,
I was in the right neighborhood, and even at the right house, I was just using the front door key that doesn't work.
Andy over in the adesk.ldd group pointed out that looking up the constant value in the vba object browser tells us that the value to use is 103.

(setq prolay (vlax-invoke-method proPref "GetString" 103))

Using that I can continue on. Thanks for looking.

Jeff

sinc

  • Guest
LDD3 and preferences
« Reply #3 on: July 23, 2004, 09:14:45 PM »
The help info is actually correct; I have no idea why they have different names for this constant in VBA and Lisp.  Autodesk works in mysterious ways sometimes.  :shock:

If you want to use the LDD constant names in Lisp (which you should - it makes your code more readable, and slightly more-likely to continue working in future versions of Autocad), you have to explicitly link the type library as follows:

Code: [Select]
(vl-load-com)

; import the Land type library
; this should only be done once, so first check to see if a
; constant defined by the type library already exists...
(if (null vll-kCurve)
  (vlax-import-type-library
    :tlb-filename "landauto.tlb"
    :methods-prefix     "vll-"
    :properties-prefix  "vll-"
    :constants-prefix "vll-"
   ) ;_ vlax-import-type-library
) ;_ if

(defun c:testfunc ()
  (setq acadObj   (vlax-get-acad-object)
aeccApp   (vla-getInterfaceObject acadObj "Aecc.Application")
aeccProj      (vll-get-activeProject aeccApp)
cogoPoints   (vll-get-cogoPoints aeccProj)
aeccPref     (vll-get-preferences aeccProj)
alignPref     (vll-get-profile aeccPref)
egLayer   (vll-getString alignPref vll-kEgLayer)
  ) ; setq
) ;_ defun


This has the advantage that the LDD commands are now registered in the Lisp editor, so (after you run the if statement above) the editor will highlight them.  This makes it easy to tell if you spelled something wrong, or are trying to use a nonexistent constant name, etc.  The resulting Lisp also runs faster, although most of the time this isn't noticeable.

If you want, you can define different prefixes for methods, properties, and constants, although I haven't found any use for this.  I just prefix everything "vll-" because it's like "vla-" except with an "L" for "Land".

Jeff_M

  • King Gator
  • Posts: 4040
  • C3D user & customizer
LDD3 and preferences
« Reply #4 on: July 25, 2004, 01:41:13 AM »
How/Where did you find this info? It's brilliant!!!!!!!In all of my perusing of newsgroups, forums, program courses, I've never seen/heard of this....

Thanks for sharing
Jeff

sinc

  • Guest
LDD3 and preferences
« Reply #5 on: July 25, 2004, 08:21:28 PM »
It's in the on-line AutoLisp developer documentation (search for "importing a type library").  :)