Jump to content

Pick a point and put the coordinates in to an exixting block.


Recommended Posts

Posted

Hello

 

I´m working in a project with a lot of doors and windows (d/w).

Each d/w have some kind off alarm.

Take a look att parment.com map PDF file 1.pdf (I´m not aloud to have a link in my messages).

 

I have insert a block outside the building and a line from the block to the d/w.

 

There ar two different blocks one for new d/w and one for existing d/w.

 

My problem is that I want to put the coordinates of the d/w into the block.

 

My idea is like this:

"Pick endpoint of line" to get the coordinates.

"Pick the block" for updating attribute "YKOORDINAT" and "XKOORDINAT".

 

I have spent a lot of time on Internet trying to find out how to do so please help me.

 

/Erik

  • Replies 21
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    10

  • BlackAlnet

    8

  • erikpar

    4

Top Posters In This Topic

Posted Images

Posted

Is it the insertion point of the block itself that you want as the attributes? or a different block's coordinates? Just to clarify :)

Posted

Take a look at pdf-file.

I updated it to make it easier to see what I meen.

The block is the rectangel and the line is just a line to mark witch door the block belongs to.

/Erik

Posted

That lisp you want is like a lisp Lee Mac write for me, maybe, i can help you. But...I can't find the pdf file.

Posted

Hello!

 

I´m not aloud to use links in my messages yet.

Take a look at parment.com/PDF/1.pdf

I´ll try to attatch an image.

/Erik

1.jpg

Posted

You want the coordinates beside the block, as a "MTEXT" or "TEXT"?

Posted
Hello!

 

I´m not aloud to use links in my messages yet.

Take a look at parment.com/PDF/1.pdf

I´ll try to attatch an image.

/Erik

 

OK Eric, I understand now - I shall see what I can do for you :)

Posted

Try this one (not tested, but i think it works...)

 

(defun c:texb ()
(setq ed (getpoint "\nPick end point of line: "))
 (while (/= ed nil)
  (setq x (car ed))
  (setq y (cadr ed))
  (setq bp (getpoint "Base point of coordenates : "))
  (command "text" "j" "tl" (list bp) "" "" (strcat "X=" (rtos x 2 3)))
  (command "text" "j" "bl" (list bp) "" "" (strcat "Y=" (rtos y 2 3)))
  (setq ed (getpoint "\nPick end point of line: "))
 )
(princ)
)

Posted

Try this:

 

{untested}

 

(defun c:Co2Blk  (/ pt bEnt bObj)
 (vl-load-com)
 (if (and (setq pt (getpoint "\nSelect Coordinate: "))
          (setq bEnt (car (entsel "\nSelect Block to Update: ")))
          (eq "AcDbBlockReference"
              (vla-get-ObjectName
                (setq bObj (vlax-ename->vla-object bEnt))))
          (eq :vlax-true
              (vla-get-HasAttributes bObj)))
   (foreach att  (vlax-safearray->list
                   (vlax-variant-value
                     (vla-getAttributes bObj)))
     (cond ((eq "XKOORDINAT"
                (vla-get-TagString att))
            (vla-put-TextString att
              (rtos (car pt))))
           ((eq "YKOORDINAT"
                (vla-get-TagString att))
            (vla-put-TextString att
              (rtos (cadr pt))))))
   (princ "\n<!> Incorrect Selection <!>"))
 (princ))


Posted
"Pick the block" for updating attribute "YKOORDINAT" and "XKOORDINAT".

/Erik

 

 

Haha, forget my lisp,I do not read that part right

Posted
Haha, forget my lisp,I do not read that part right

 

Its still great that you took at stab at writing one though :thumbsup:

Posted

But, just as a tip if you don't mind me saying so,

 

When automating text insertion (or Attribute creation), it is much better to use either a method using entmake or a vl method - as the prompts for the text and attribute creation can change from version to version and machine to machine. :thumbsup:

Posted
Its still great that you took at stab at writing one though :thumbsup:

 

 

Yes, in my job, i create some lisps, do draw and extract some things. Because of this i've become promoted.(i'm that job 2 months only).

 

So, if i only read about lisp, and not "took at stab at writing one though", i never really will now about lisps.

 

All tips is welcome, thanks for help me!!

Posted
Yes, in my job, i create some lisps, do draw and extract some things. Because of this i've become promoted.(i'm that job 2 months only).

 

So, if i only read about lisp, and not "took at stab at writing one though", i never really will now about lisps.

 

All tips is welcome, thanks for help me!!

 

Promoted through LISP eh...? I wonder how many people have been promoted for using a LISP I wrote for them... :P

Posted

LeeMac, your program works perfectly.

BlackAlnet, I tried to explain as best I could.

Now I find someone who can do the job.

There are about 2,000 blocks to be updated.

 

/Erik

Posted
LeeMac, your program works perfectly.

BlackAlnet, I tried to explain as best I could.

Now I find someone who can do the job.

There are about 2,000 blocks to be updated.

 

/Erik

 

Thanks Erik, I feel sorry for the poor guy who will have to go through all 2000 blocks with this... :P

Posted
Promoted through LISP eh...? I wonder how many people have been promoted for using a LISP I wrote for them... :P

 

 

Haha, your lisp. That lisp of extraction was too complicated, did not like being me. I never say that is my lisp. But i write simple lisps, and that was enough for promote...

 

 

I aways say i'm getting help from this forum. The problem is, i think, no one here understand how to write lisps.

 

i'm glad for your help, tips, and explain me things about lisp!! And i want write more and more lisps.

Posted
Haha, your lisp. That lisp of extraction was too complicated, did not like being me. I never say that is my lisp. But i write simple lisps, and that was enough for promote...

 

:) I know, I was just jokin' :)

 

I aways say i'm getting help from this forum. The problem is, i think, no one here understand how to write lisps.

 

i'm glad for your help, tips, and explain me things about lisp!! And i want write more and more lisps.

 

I'm happy to give you tips and help as much as I can :)

Posted
But, just as a tip if you don't mind me saying so,

 

When automating text insertion (or Attribute creation), it is much better to use either a method using entmake or a vl method - as the prompts for the text and attribute creation can change from version to version and machine to machine. :thumbsup:

 

 

Ok, i think abou it, and i make this

 

(defun c:yy2 ()
 (setq ed(getpoint "\nSelect end point: "));select the point of coords
 (while (/= ed nil);loop
  (setq x (car ed));x coord
  (setq y (cadr ed));y coord
   (setq bp (getpoint "\nBase point for coord: "))
   (entmake ((0 . "TEXT")(1 . (x))(72 . 2)(73 . 3)(40 . 2,5)(10 . bp)))
   (entmake ((0 . "TEXT")(1 . (y))(72 . 2)(73 . 1)(40 . 2,5)(10 . bp)))
   (setq ed(getpoint "\nSelect end point: "))
   )
 (princ)
 )

 

 

Why it doesn't work? What's wrong??

Posted
Why it doesn't work? What's wrong??

 

Just about everything... :geek:

 

(defun c:yy2  (/ ed x y bp) ; Make sure you localise your variables!
 (while (setq ed (getpoint "\nSelect end point: "))
   (setq x (car ed) y (cadr ed)
         bp (getpoint "\nBase point for coord: "))
   (entmake
     (list
       (cons 0 "TEXT")
       (cons 1 (rtos x)) ; Needs a string
       (cons 72 2)
       (cons 73 3)
       (cons 40 2.5) ; Real numbers cannot use commas
       (cons 10 bp)
       (cons 11 bp))) ; Needs alignment Point
   (entmake
     (list
       (cons 0 "TEXT")
       (cons 1 (rtos y))
       (cons 72 2)
       (cons 73 1)
       (cons 40 2.5)
       (cons 10 bp)
       (cons 11 bp))))
 (princ))

 

Firstly, remember to localise your variables.

 

With the entmake lists, they need to be lists so use the "list" function.

 

Use cons to group elements into dotted pairs.

 

real numbers need decimals, not commas

 

the content of the text (group 1) needs to be a string

 

They need to have an allignment point group 11

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...