Originally Posted by
rmk
Thanks BlackBox.....that's exactly what I have been doing. Haven't found any other way yet.
You're welcome; you can write yourself a small LISP which would prompt for a points file, and point range (presuming a given format; PNEZD, etc.), and then programmatically open the selected point file for read, and write each matching entry to a new temporary point file, and then either open the resultant point file in the default application (Notepad, Notepad++, etc.) so user can review prior to saving to your project.
... Or you could just import the desired point range as COGO Points, like so... As example, use 750-800 as range (instead of entering low, and then entering high separately), duplicate Points are automagically renumbered, and UNDO functionality is supported:
Code:
(vl-load-com)
(defun c:ImportPointRange (/ *error* BBOX:Parser vrsn filePath range low
high acApp aeccApp aeccPoints acDoc file l
data n oCogo err
)
;; Sample for importing PNEZD point range
(defun *error* (msg)
(if aeccApp
(vlax-release-object aeccApp)
)
(if file (close file))
(if acDoc
(vla-endundomark acDoc)
)
(cond ((not msg)) ; Normal exit
((member msg '("Function cancelled" "quit / exit abort"))) ; <esc> or (quit)
((princ (strcat "\n** Error: " msg " ** "))) ; Fatal error, display it
)
(princ)
)
(defun BBOX:Parser (char string / i segments segment)
;; BlackBox
;; Example: (BBOX:Parser "-" "dd-mm-yyyy")
;; Returns: ("dd" "mm" "yyyy")
(while (setq i (vl-string-search char string))
(setq
segments (cons (setq segment (substr string 1 i)) segments)
)
(setq string (substr string (+ 2 i)))
)
(reverse (cons string segments))
)
(if
(and
(setq vrsn
(if vlax-user-product-key ; If 2013+
(vlax-user-product-key) ; Use new function
(vlax-product-key) ; Use legacy function
)
)
(cond
((vl-string-search "R20.0" vrsn) (setq vrsn "10.4")) ; 2015
((vl-string-search "R19.1" vrsn) (setq vrsn "10.3")) ; 2014
((vl-string-search "R19.0" vrsn) (setq vrsn "10.0")) ; 2013
((vl-string-search "R18.2" vrsn) (setq vrsn "9.0")) ; 2012
((vl-string-search "R18.1" vrsn) (setq vrsn "8.0")) ; 2011
((vl-string-search "R18.0" vrsn) (setq vrsn "7.0")) ; 2010
((vl-string-search "R17.2" vrsn) (setq vrsn "6.0")) ; 2009
(T (prompt "\n** This version not supported ** "))
)
(setq filePath
(getfiled "Select point file"
(if *ImportPointRangePath*
*ImportPointRangePath*
(getvar 'dwgprefix)
)
""
8
)
)
(setq *ImportPointRangePath* filePath)
(setq range (getstring "\nEnter point number range (1-25): "))
(wcmatch range "*-*")
(setq range (vl-sort (BBOX:Parser "-" range) '<))
(setq low (car range))
(setq high (last range))
(princ "\nWorking, please wait...")
(princ)
(setq acApp (vlax-get-acad-object))
(setq aeccApp (vla-getinterfaceobject
acApp
(strcat "AeccXUiLand.AeccApplication." vrsn)
)
)
(setq aeccPoints
(vlax-get-property
(vlax-get-property
(vlax-get-property aeccApp "ActiveDocument")
"Database"
)
"Points"
)
)
)
(progn
(vla-startundomark
(setq acDoc (vla-get-activedocument acApp))
)
(setq file (open filePath "r"))
(while (setq l (read-line file))
(setq data (BBOX:Parser "," l))
(if
(and (<= (setq n (car data)) high)
(>= n low)
)
(progn
(setq oCogo
(vlax-invoke-method
aeccPoints
"Add"
(vlax-3d-point
(list (atof (cadr data))
(atof (caddr data))
(atof (cadddr data))
)
)
)
)
(vla-put-description oCogo (last data))
(if
(vl-catch-all-error-p
(vl-catch-all-apply
'vlax-put-property
(list oCogo "Number" n)
)
)
(prompt
(strcat "\nPoint number \""
n
"\" already exists, renumbered as \""
(itoa (vlax-get-property oCogo "Number"))
"\" "
)
)
)
)
)
)
(setq file (close file))
(if oCogo
(princ "Done. ")
(prompt "\n** No points found in that range ** ")
)
)
)
(*error* nil)
)
Cheers