Author Topic: Can't save changes to COGO points to the project database  (Read 4444 times)

0 Members and 1 Guest are viewing this topic.

sinc

  • Guest
Can't save changes to COGO points to the project database
« on: July 30, 2004, 07:44:53 PM »
Anybody have any idea what's going on here?  The following routine datum-adjusts cogo points to the elevation of the current surface at that point.  When I run it, the point is correctly changed in the drawing, but not in the project.

The debug statement in the code that checks the value of autoSave says that it is ENABLED, which the documentation seems to indicate means that changes to points are written to the project as soon as they are made (they are not).  The documentation says that I should be able to use CogoPoint's save method to update the database, but that returns a "Name not found" ActiveX error.  A vlax-dump-object reveals that the CogoPoint actually has an update method, not a save method, but adding a line to call this method as shown is ineffective.

As it is, I can run Check Points -> Modify Project after running this routine, but I'd like to figure out what's going on.

Code: [Select]
(vl-load-com)
(if (= nil 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:pt2surf (/     acadObj aeccApp   aeccProj
 cogoPoints surfaces curSurf   ss
 pt
)
  (setq acadObj   (vlax-get-acad-object)
aeccApp   (vla-getInterfaceObject acadObj "Aecc.Application")
aeccProj   (vll-get-activeProject aeccApp)
cogoPoints (vll-get-cogoPoints aeccProj)
surfaces   (vll-get-surfaces aeccProj)
curSurf   (vll-item surfaces
    (vll-get-currentSurface surfaces)
  ) ;_ vll-item
ss   (ssget '((0 . "AECC_POINT")))
count   (sslength ss)
index   -1
  ) ;_ setq
  (if (vll-get-autoSave cogoPoints)
    (princ "\nAutosave ENABLED")
    (princ "\nAutosave DISABLED")
  ) ;_ if
  (while (< (setq index (1+ index)) count)
    (setq pt (vlax-ename->vla-object (ssname ss index)))
    (vll-put-elevation
      pt
      (vll-getElevation
curSurf
(vll-get-easting pt)
(vll-get-northing pt)
      ) ;_ vll-getElevation
    ) ;_ vll-put-elevation
;    (vll-update pt) ; can uncomment this, but appears to have no effect
  ) ;_ foreach
  (princ)
) ;_ defun

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Can't save changes to COGO points to the project database
« Reply #1 on: July 30, 2004, 08:09:47 PM »
Take a look at this code, i think you need to access the cogo point from the database itself.
Code: [Select]

;   ,-----------------------------------------------,
;   |             INPUT DIALOG BOX                  |
;   '-----------------------------------------------'
;
(defun InputDesc (prompt1 title default)

  (setq dcl_id (load_dialog "inputbox.dcl"))
  (if (not (new_dialog "inputbox" dcl_id))
    (exit)
    )

  (set_tile "prompt" prompt1)
  (set_tile "title" title)
  (set_tile "eb1" default)
  (mode_tile "eb1" 2)

  (action_tile
    "cancel"
    "(done_dialog)
    (setq e-result nil)"
    )
  (action_tile
    "accept"
    "(setq inputvalue (get_tile \"eb1\"))
    (done_dialog)
    (setq e-result T)"
    )
  (start_dialog)
  (unload_dialog dcl_id)
  (princ)
  ); defun

;   ,-----------------------------------------------,
;   |             CogoPoint Object                  |
;   '-----------------------------------------------'
;
(defun GetCogoObj (/ AeccApp AeccProject CogoPointObj)

  (vl-load-com)
  (vl-catch-all-apply
    (function
      (lambda ()
        (setq
          AeccApp
          (vla-getinterfaceobject
            (vlax-get-acad-object) "Aecc.Application" )
          )
        (setq
          AeccProject
          (vlax-get-property AeccApp 'ActiveProject)
          )
        (setq
          CogoPointObj
          (vlax-get-property AeccProject 'CogoPoints)
          )
        ); lambda
      ); function
    )
  ); defun


;   ,-----------------------------------------------,
;   |             POINT SELECTION                   |
;   '-----------------------------------------------'
;
(defun PointSelection (/ ss obj)

  (princ "\nSelect One Point ONLY")

  (if
    (setq ss (ssget ":E:S" '((0 . "AECC_POINT"))))

    (cond
      ((= (sslength ss) 1)
       (setq obj (vlax-ename->vla-object (ssname ss 0)))
       ); 1st cond
      ((> (sslength ss) 1)
       (alert "**Incorrect Selection**\n\nTo Many Points Selected")
       ); 2nd cond
      ); cond
    ); if
  ); defun

;   ,-----------------------------------------------,
;   |               MAIN FUNCTION                   |
;   '-----------------------------------------------'
;
(defun c:celev (/ kwd pnts LockedPoints
                  cogopt ptnum cgpnt1 pntelev
                  newelev e-result)

  (vl-load-com)

  ;;------- error function
  (defun *error* (msg)
    (if
      (not (member msg
                   '("console break" "Function cancelled" "quit / exit abort"))
           )
      (princ (strcat "\nError: " msg))
      ); if
    (princ)
    )
  ;;------- error function

  (setq
    pnts (GetCogoObj)
    LockedPoints (LockedPointsList)
    )

  (if
    (setq cogopt (PointSelection))
    (setq ptnum (vlax-get-property cogopt 'Number))
    ); if

  (if
    (member ptnum LockedPoints)
    (progn
      (alert "Selected Point is Locked")
      (setq ptnum nil)
      )
    ); if
 
  (if
    ptnum
    (progn
      (setq
        cgpnt1 (vlax-invoke-method pnts 'PointByNumber ptnum)
        pntelev (vlax-get-property cgpnt1 'Elevation)
        )
      (InputDesc "Enter Elevation" " Change Elevation" (rtos pntelev))
      (if e-result
        (progn
          (setq newelev (atof inputvalue))
          (vlax-put-property cgpnt1 'Elevation newelev)
          (vlax-release-object cogopt)
          (vlax-release-object cgpnt1)
          )
        );if
      ); progn
    ); if

  (princ)

  ); defun celev
TheSwamp.org  (serving the CAD community since 2003)

sinc

  • Guest
Can't save changes to COGO points to the project database
« Reply #2 on: July 30, 2004, 09:23:42 PM »
The only line of note that I see is this:

(vlax-release-object cogopt)

That looks like it might be important.

Unfortunately, I have to wait until I get back to the office to try it.  Something's wrong with my installation at home, and I get "ActiveX server returned an error: Library not registered" every time I try to access the Aecc application.  No matter what I try, I haven't been able to fix this.  I think I have a type library or dll registration corrupted, but I don't know how to figure out which one or how to fix it...  Re-registering landauto.tlb doesn't seem to fix the problem...  Uninstalling and reinstalling Autocad didn't solve the problem...  I might have to reinstall Windows (and everything else)...   :evil:

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Can't save changes to COGO points to the project database
« Reply #3 on: August 02, 2004, 11:10:23 AM »
the line (setq pt (vlax-ename->vla-object (ssname ss index))) is getting the AECC_POINT not the point number in the points DB. That's why you have to run update points. The AECC_POINT is in the dwg and the COGO point is in the points.mdb file. Two different animals. :D
TheSwamp.org  (serving the CAD community since 2003)

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Can't save changes to COGO points to the project database
« Reply #4 on: August 02, 2004, 11:22:28 AM »
try this :
Code: [Select]

(defun c:pt2surf (/ acadObj aeccApp   aeccProj
 cogoPoints surfaces curSurf   ss
 pt
 )
  (setq acadObj   (vlax-get-acad-object)
aeccApp   (vla-getInterfaceObject acadObj "Aecc.Application")
aeccProj   (vll-get-activeProject aeccApp)
cogoPoints (vll-get-cogoPoints aeccProj)
surfaces   (vll-get-surfaces aeccProj)
curSurf   (vll-item surfaces
(vll-get-currentSurface surfaces)
) ;_ vll-item
)
  (setq
ss  (ssget '((0 . "AECC_POINT")))
count (sslength ss)
index -1
) ;_ setq


  (if (vll-get-autoSave cogoPoints)
(princ "\nAutosave ENABLED")
(princ "\nAutosave DISABLED")
) ;_ if



  (while (< (setq index (1+ index)) count)
(setq pt_num (cdr (assoc 90 (entget (ssname ss index)))))
(setq pt (vlax-invoke-method cogoPoints 'PointByNumber pt_num))

(vll-put-elevation
 pt
 (vll-getElevation
curSurf
(vll-get-easting pt)
(vll-get-northing pt)
) ;_ vll-getElevation
 ) ;_ vll-put-elevation

(vlax-release-object pt)
)
 

  (princ)
  )
TheSwamp.org  (serving the CAD community since 2003)

sinc

  • Guest
Can't save changes to COGO points to the project database
« Reply #5 on: August 02, 2004, 11:38:52 AM »
Ah, now that I'm back in the office, I see that the objects gotten in the selection set are AeccPoint objects, and the object I need to change is an AeccCogoPoint object.

I don't suppose there's a default function somewhere that does this conversion (AeccPoint <-> AeccCogoPoint)?  It's simple enough to write one, but this seems like the sort of thing that should already exist.  In fact, I'm sure it does; the question is, did Autocad expose it so that Lisp programmers can use it?

That seems to be a general failing in the Autocad APIs that I've been noticing.  They've documented the object model relatively well, but if they allow Lisp programmers to access various helper routines, they've hidden that fact.  For example, there should be a routine that will set the description for a newly-created cogo point based on the point settings (prompting the user to enter the description if necessary).  I assume one exists; Autocad routines do this enough.  But if Lisp programmers can access the routine, that fact isn't well-documented, so I had to write my own...

sinc

  • Guest
Can't save changes to COGO points to the project database
« Reply #6 on: August 07, 2004, 03:42:02 PM »
Quote from: Mark Thomas
try this :

Heh, I just happened to look at this old thread, and saw your last two posts.  Looks like you replied after I started typing my reply...  Things were a bit hectic that morning, and I never saw them...  :)

Yeah, I pretty much did the exact same thing you suggested.  Thanks.