Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Iterative Object Information

7 REPLIES 7
Reply
Message 1 of 8
david_garrigues
344 Views, 7 Replies

Iterative Object Information

Iterative Object Information

Hey Everyone,

I have a question regarding delving deep into an object. Please note that I am not accustomed to the vernacular spoken here about objects I only know enough to go and grab an objects information. The code below will allow the user to select an object and dump that info for them. If the parameter that they are looking for has an additional object it will gather that info for them. This only works on the first level of an object. So what I did was place a little string of text (code) that I can copy later on to the command line if I need to dig deeper.

My question- Is it possible to generate something that will constantly allow the user to get deeper and deeper into an object? Maybe even something that allows you to back up one-two-three.. times because the path you took did not get you where you wanted to go?

(defun c:getobjinfo ()
(setq *acad* (vlax-get-acad-object)
*doc* (vlax-get-property *acad* 'activedocument)
)
(setq ent (car (entsel)))
(setq objent (vlax-ename->vla-object ent))
(vlax-dump-object objent)
(princ)
(textscr)
(setq PropName (getstring "\nEnter Property name: "))
(setq HasDeeperEntity nil)
(setq HasDeeperEntity (strcase (getstring "\nDoes it have sub information?: ")));just hit enter if no
(setq rv nil)
(if (/= PropName "")
(setq rv1 (vlax-get objent propname))
)
(princ rv1)
(if (or
(= HasDeeperEntity "YES")
(= HasDeeperEntity "Y")
)
(progn
(vlax-dump-object (vlax-get objent propname))
(princ "\n(Vlax-dump-object (vlax-get (vlax-get objent propname) 'YourNameHere))")
(princ)
)
)
)

Maybe there is a simpler way of achieving the same thing I just thought it would easier to follow when I create my code if I knew where I was going 🙂

Thank you in advance.
dg
7 REPLIES 7
Message 2 of 8
Anonymous
in reply to: david_garrigues

Hello, David.



I don't do alot with vla-objects so It was a learning experience for me.
So thanks for posting this.


Here is what I have so far.
Its quite different from what you had but I had to change it for it to make sense to me.
Try it out and let me know what you think.
{code}

;;Start On a selection object.
(defun c:getobjinfo ()
(setq global_objlist ( list (vlax-ename->vla-object ( car ( entsel )))))
( readobject )
(princ))



;; this is the main view object function with options. "*" backs up.
;; if you want to restart viewing the current vla-object withought selecting an object you can enter ( readobject )
( defun readobject ( / PropName )
( setq globalobject ( last global_objlist ) )
( vlax-dump-object globalobject )
( textscr )
( princ "\n---------------------------" )(princ)
(setq PropName (getstring "\nEnter Property name: "))

( if ( and ( = "*" PropName )
( > ( length global_objlist ) 1 ) );a
( progn
( storobjlist ( nth ( - ( length global_objlist ) 2 ) global_objlist ) )
);p
( progn

( if (vlax-property-available-p globalobject PropName )
( progn
( if ( = ( type ( vlax-get globalobject PropName )) ( read "VLA-OBJECT" ) )
( storobjlist ( vlax-get globalobject PropName ))
( princ ( vlax-get globalobject PropName ))
);i
( princ )
);p
( progn
( princ "\nProperty Not availible, Please Re-Enter." )(princ)
( readobject )
);p
);i

);p
);i
);d

;; here i store a list of Objects viewed so that you can back up.
( defun storobjlist ( obj_in )
( if ( = ( type obj_in) ( read "VLA-OBJECT" ) )
( progn
( if global_objlist
( progn
( if ( member obj_in global_objlist )
( setq global_objlist ( reverse ( member obj_in ( reverse global_objlist ))))
( setq global_objlist ( append global_objlist ( list obj_in)))
);i
( readobject )
);p
);i
);p
);i
);d
{code}
Message 3 of 8
Anonymous
in reply to: david_garrigues

I think some of what you want is available in the object browser in vlide.


wrote in message
news:6242676@discussion.autodesk.com...
Iterative Object Information

Hey Everyone,

I have a question regarding delving deep into an object. Please note that I
am not accustomed to the vernacular spoken here about objects I only know
enough to go and grab an objects information. The code below will allow the
user to select an object and dump that info for them. If the parameter that
they are looking for has an additional object it will gather that info for
them. This only works on the first level of an object. So what I did was
place a little string of text (code) that I can copy later on to the command
line if I need to dig deeper.

My question- Is it possible to generate something that will constantly allow
the user to get deeper and deeper into an object? Maybe even something that
allows you to back up one-two-three.. times because the path you took did
not get you where you wanted to go?

(defun c:getobjinfo ()
(setq *acad* (vlax-get-acad-object)
*doc* (vlax-get-property *acad* 'activedocument)
)
(setq ent (car (entsel)))
(setq objent (vlax-ename->vla-object ent))
(vlax-dump-object objent)
(princ)
(textscr)
(setq PropName (getstring "\nEnter Property name: "))
(setq HasDeeperEntity nil)
(setq HasDeeperEntity (strcase (getstring "\nDoes it have sub
information?: ")));just hit enter if no
(setq rv nil)
(if (/= PropName "")
(setq rv1 (vlax-get objent propname))
)
(princ rv1)
(if (or
(= HasDeeperEntity "YES")
(= HasDeeperEntity "Y")
)
(progn
(vlax-dump-object (vlax-get objent propname))
(princ "\n(Vlax-dump-object (vlax-get (vlax-get objent propname)
'YourNameHere))")
(princ)
)
)
)

Maybe there is a simpler way of achieving the same thing I just thought it
would easier to follow when I create my code if I knew where I was going 🙂

Thank you in advance.
dg
Message 4 of 8

Oh My Goodness! That is awesome!!!

Can I ask one more little question? is there a way we can iterate through items that have a count value assigned? While I mostly use Civil 3D there are times when there are multiple surfaces, alignments, etc but since we have AutoCAD as the base lets just use TextStyles as the example. Using your FREAKING AWESOME program I can just select a line in the drawing and then type in DOCUMENT. This gets me to the top from here I can see TEXTSTYLES. Now I know I can do this to get all the names.

(vlax-for styles (vla-get-textstyles
(vla-get-activedocument
(vlax-get-acad-object)
)
)
(princ (strcat "\n" (vla-get-name styles)))
)

But to do that I am not inside your program is there a way to cycle through any item that has a count value?
eg
Enter Property name (or * to Backup): textstyles

; IAcadTextStyles: The collection of all text styles in the drawing
; Property values:
; Application (RO) = #
; Count (RO) = 39 **************<<<<<<<<<<<<<<<<<<<
; Document (RO) = #
; Handle (RO) = "3"
; HasExtensionDictionary (RO) = 0
; ObjectID (RO) = 2124868632
; ObjectName (RO) = "AcDbTextStyleTable"
; OwnerID (RO) = 0

Thanks for the program it truly is awesome!
thanks
dg
Message 5 of 8

Hey Doug,
You are absolutely right and in a way it is was gave me the idea...but sometimes I don't want to code something right now I just want to examine the object to figure out if it is what I want to do? With Civil 3D maybe not all the objects properties are available or if they are I just need the name so rather than launching all the code necessary to get me my value I can use this instead.

hth
dg
Message 6 of 8
Anonymous
in reply to: david_garrigues

As far as using my program on vla-objects

All "getobjinfo" really does is set a variable "global_objlist" and then starts "readobject" that uses the list to read the last object.

So you can go.

( setq global_objlist ( list **ANY-VLA-OBJECT*** )))
( readobject )
and you will be in the program




And by wanting to go through the count of objects I believe you would have to invoke a method. And get a collection.
I don't use vla-objects a lot but I will definitely look into successfully doing this.



I'm really glad that worked out for you the first time. 😄
Message 7 of 8
Anonymous
in reply to: david_garrigues

Without a huge program, I doubt you could track down any particular
collection without having coded all the property access functions for that
collection. So unless you had very specific needs with a very narrow set of
objects, the time to code would exceed the benefits to have coded it.
Tony Tanzillo has created an excellent object browser for his .net use but I
doubt it was a weekend project.

wrote in message
news:6243024@discussion.autodesk.com...
Hey Doug,
You are absolutely right and in a way it is was gave me the idea...but
sometimes I don't want to code something right now I just want to examine
the object to figure out if it is what I want to do? With Civil 3D maybe
not all the objects properties are available or if they are I just need the
name so rather than launching all the code necessary to get me my value I
can use this instead.

hth
dg
Message 8 of 8
Anonymous
in reply to: david_garrigues

I think it can definitely work. But how to have the user input info is a little difficult to work with.

Since we don't know the style names. then you would have to put in "Count" property. then have the program respond with the first style in the count list.


Example:
{code}
; IAcadTextStyle: A named, saved collection of settings that determines the
appearance of text characters
; Property values:
; Application (RO) = #
; BigFontFile = ""
; Document (RO) = #
; fontFile = "txt"
; Handle (RO) = "26"
; HasExtensionDictionary (RO) = 0
; Height = 0.0
; LastHeight = 0.2
; Name (RO) = "STANDARD"
; ObjectID (RO) = 2128776496
; ObjectName (RO) = "AcDbTextStyleTableRecord"
; ObliqueAngle = 0.0
; OwnerID (RO) = 2128776488
; TextGenerationFlag = 0
; Width = 1.0
{code}


And then there is no way to go to the next text style. Unless you just have it print out all of the object info for each text style .. witch we can do.
Or we make a different program to handle Count objects and then you would type Next or Back for the Text styles? But then * would have to take you back to the "vla-get-textstyles" object.
I've Been a bit busy with other things so its taking a while... but kinda tinkering with ideas in my head.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report