Get point of X,Y coord. from Xref object

Get point of X,Y coord. from Xref object

Automohan
Advocate Advocate
1,816 Views
14 Replies
Message 1 of 15

Get point of X,Y coord. from Xref object

Automohan
Advocate
Advocate

Dear Colleagues,

 

Will a Lisp function will choose a point object X,Y coordinate from Xref with a specific layer?

 

Kind Regards

"Save Energy"
Did you find this reply helpful? If so please use the Accept as Solution
0 Likes
1,817 Views
14 Replies
Replies (14)
Message 2 of 15

-didier-
Advisor
Advisor

Bonjour @Automohan 

 

  1. I don't quite understand the question
    Do you want to use getpoint?... It will work
  2. Do you want to know the coordinates of a specifically defined point (intersection, extremity, of an entity)
    located in the xref?

 

Amicalement

Éternel débutant.. my site for learning : Programmer dans AutoCAD

DA

EESignature

0 Likes
Message 3 of 15

Automohan
Advocate
Advocate

CAD Tutor.jpg

White color rectangle (Drawing border) + red color point + green color point are Xref ojects !

For the Pagesetup lisp red color point X,Y & green color point X,Y is required !

Note:

Red color point is not layer 1, it should be layer 2

Green color point is not layer 1, it should be layer 3

---------------------------------

Getpoint of X,Y coord. of a point on a specific layer 2

Getpoint of X,Y coord. of a point on a specific layer 3

"Save Energy"
Did you find this reply helpful? If so please use the Accept as Solution
0 Likes
Message 4 of 15

Sea-Haven
Mentor
Mentor

If its a rectang title block etc the (getvar 'extmax & extmin may give you what you want.

0 Likes
Message 5 of 15

-didier-
Advisor
Advisor

Bonjour @Automohan 

 

These explanations do not allow me to understand

 

  • These points are unique?
  • One point per layer?
  • They are blocks?

Please show an example of dwg with xrefs

 

AMicalement

Éternel débutant.. my site for learning : Programmer dans AutoCAD

DA

EESignature

0 Likes
Message 6 of 15

Moshe-A
Mentor
Mentor

@Automohan ,

 

As @-didier-  said, your explanations are not clear at all. to get the coordinates of an xref, you can do something similar as the attached code (BB command). (vla-BoundingBox) function can return the surrounding box of any object. it returns the minpoint which is the lower left corner and maxpoint which is the upper right corner. from there you can easily figure your points 😀

 

enjoy

Moshe

 

; return bounding box of block references
(defun c:BB (/ ss AcDbBlkRef MinPoint MaxPoint p0 p1)
 (if (setq ss (ssget ":s:e+." '((0 . "insert"))))
  (foreach ename (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
   (setq AcDbBlkRef (vlax-ename->vla-object ename))

   (vla-GetBoundingBox AcDbBlkRef 'MinPoint 'MaxPoint)

   (setq p0 (vlax-safearray->list MinPoint))  
   (setq p1 (vlax-safearray->list MaxPoint))

   (foreach a (list p0 " " p1) 
    (princ a)
   )  

   (vlax-release-object AcDbBlkRef) 
  ); foreach
 ); if

 (princ) 
)

 

0 Likes
Message 7 of 15

Automohan
Advocate
Advocate

Our drawing frames all are Xrefs only (not blocks)

I have attached our drawing frame cad format.

"Save Energy"
Did you find this reply helpful? If so please use the Accept as Solution
0 Likes
Message 8 of 15

john.uhden
Mentor
Mentor

Why not just do a pagesetup first, then there's no need to go picking around thereafter.

Then again, if you're not using paperspace, you should be.

John F. Uhden

0 Likes
Message 9 of 15

Moshe-A
Mentor
Mentor

@Automohan ,

 


@Automohan wrote:

Dear Colleagues,

 

Will a Lisp function will choose a point object X,Y coordinate from Xref with a specific layer?

 

Kind Regards


Getting an XY coordinates of a point in cross layers. a point on "layer1" is the same point on "layer2"...."layerN"

so we not exactly understand what you mean by "coordinate from Xref with a specific layer?"

 

"Our drawing frames all are Xrefs only (not blocks)"

for your knowledge, an xref is private case of a block.

 

attached an update to BB command.

 

Moshe

 

; return bounding box of block references
(defun c:BB (/ ss AcDbBlkRef MinPoint MaxPoint p0 p1 p2 p3)
 (if (setq ss (ssget ":s:e+." '((0 . "insert"))))
  (foreach ename (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
   (setq AcDbBlkRef (vlax-ename->vla-object ename))

   (vla-GetBoundingBox AcDbBlkRef 'MinPoint 'MaxPoint)

   (setq p0 (vlax-safearray->list MinPoint))  
   (setq p2 (vlax-safearray->list MaxPoint))

   (setq p1 (list (car p2) (cadr p0)))
   (setq p3 (list (car p0) (cadr p2)))
    
   (foreach a (list p0 " " p1 " " p2 " " p3) 
    (princ a)
   )  
    
   (vlax-release-object AcDbBlkRef) 
  ); foreach
 ); if

 (princ) 
)

 

 

0 Likes
Message 10 of 15

Sea-Haven
Mentor
Mentor

As suggested if in a layout with 1 xref title block this may be useful.

 

(setq ss (ssget "X" (list (cons 0 "INSERT")(cons 2 "yourxrefame")(cons 410 (getvar 'ctab)))))

 

0 Likes
Message 11 of 15

john.uhden
Mentor
Mentor
But why would he need one PS coordinate to plot?
Pagesetup... ready to plot (again and again).
I wonder if he's heard about Sheet Set Manager.

John F. Uhden

0 Likes
Message 12 of 15

Automohan
Advocate
Advocate

Getting Error !

Error tapping.jpg

"Save Energy"
Did you find this reply helpful? If so please use the Accept as Solution
0 Likes
Message 13 of 15

Automohan
Advocate
Advocate

I never use Sheet Set Manager I have to go through it !

I know i can do a Pagesetup & insert to many drawings & apply, but some drawings got moved mistakenly (error)

My Idea is to create a Page setup lisp then load with a Script to run.

I look forward to hear your opinion or any ideas.

"Save Energy"
Did you find this reply helpful? If so please use the Accept as Solution
0 Likes
Message 14 of 15

Moshe-A
Mentor
Mentor

@Automohan ,

 

Never heard c:bb is a protected symbol but you are invited to change it to what ever you choose

 

Moshe

 

0 Likes
Message 15 of 15

john.uhden
Mentor
Mentor

Is your idea based on previous programming experience or is it wishful thinking?

There are many fine people here who donate their time with the intent of helping others learn to improve their AutoLisp programming skills.  Yet there is a plethora of visitors who just want a custom solution built for them for free to save them time and effort.  Ya know, if such needy visitors were willing to pay for the expertise they receive it would be fair.  But a very very few are willing, and it bugs the $#*^! out of me.

My apologies if I have misinterpreted your intent.

John F. Uhden

0 Likes