Author Topic: Create Field from 2 block attributes.  (Read 2524 times)

0 Members and 1 Guest are viewing this topic.

LSElite

  • Newt
  • Posts: 65
Create Field from 2 block attributes.
« on: January 10, 2016, 06:47:53 PM »
Hey All

I am making a tagging program where the user clicks a block and places a tag at the cursor.
What I need for the Tag is an updating field.
the field needs to reference the attribute values and find the distance between the elevations.
eg:
100 and 500 = 400
-100 and 500 = 600
-500 and 0 = 500

I can do this however it would not make a field of the value.
Does anyone know if this can be achieved with a field or a diesel expression?

Cheers
“A life spent making mistakes is not only more honorable, but more useful than a life spent doing nothing.”
― George Bernard Shaw

mianbaoche

  • Guest
Re: Create Field from 2 block attributes.
« Reply #1 on: January 10, 2016, 07:53:05 PM »
Code - Auto/Visual Lisp: [Select]
  1. (defun c:kk()
  2. (setq lst (list '(100 400) '(-100 400) '(100 -400) '(-100 -400)))
  3. (mapcar '(lambda (x) (if (= (minusp (car x)) (minusp (cadr x)))
  4.                        (abs (- (car x) (cadr x) ))
  5.                        (+ (abs (car x))(abs (cadr x)))
  6.                        )) lst)
  7.   )

LSElite

  • Newt
  • Posts: 65
Re: Create Field from 2 block attributes.
« Reply #2 on: January 10, 2016, 11:10:50 PM »
So I have found most of what I need to make this work.
All i need now is how to find the VLA object for the attributes in the selected block.
Anyone know how to return all VLA Attribute Objects from a block?
“A life spent making mistakes is not only more honorable, but more useful than a life spent doing nothing.”
― George Bernard Shaw

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: Create Field from 2 block attributes.
« Reply #3 on: January 11, 2016, 01:43:16 AM »

LSElite

  • Newt
  • Posts: 65
Re: Create Field from 2 block attributes.
« Reply #4 on: January 11, 2016, 03:16:38 AM »
Thanks HasanCAD
I cant figure out how the attribute entities work though.
Ill keep working at it but a steer in right direction would be appreciated.
I just need the VLA-Entity for an attribute named "Elevation" in a selected block.

Cheers
“A life spent making mistakes is not only more honorable, but more useful than a life spent doing nothing.”
― George Bernard Shaw

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Create Field from 2 block attributes.
« Reply #5 on: January 11, 2016, 03:59:36 AM »
Code - Auto/Visual Lisp: [Select]
  1.   '(lambda (attObj)
  2.     (if (= (strcase (vla-get-tagstring attObj)) str)
  3.       attObj
  4.     )
  5.   )
  6.   (vlax-invoke blockRefObj 'getattributes)
  7. )

LSElite

  • Newt
  • Posts: 65
Re: Create Field from 2 block attributes.
« Reply #6 on: January 11, 2016, 05:25:13 PM »
'GetAttributes was exactly what I was looking for.
Cheers Roy
“A life spent making mistakes is not only more honorable, but more useful than a life spent doing nothing.”
― George Bernard Shaw

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: Create Field from 2 block attributes.
« Reply #7 on: January 11, 2016, 08:27:02 PM »
I believe this link will give you more help
http://www.lee-mac.com/attributefunctions.html

LSElite

  • Newt
  • Posts: 65
Re: Create Field from 2 block attributes.
« Reply #8 on: January 12, 2016, 01:28:26 AM »
Cheers Hansan   :-)
“A life spent making mistakes is not only more honorable, but more useful than a life spent doing nothing.”
― George Bernard Shaw