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

using vlax-get-property

32 REPLIES 32
Reply
Message 1 of 33
Anonymous
626 Views, 32 Replies

using vlax-get-property

I need to be able to pick a style object and return the name. The following
works fine, unless object picked has no style name, like a line or circle.

(setq OBJ (vlax-ename->vla-object (car (entsel))))
(vlax-get-property OBJ "StyleName")

What is the proper way to test the second line without bombing my function?

Thank you,
Mark
32 REPLIES 32
Message 21 of 33
Anonymous
in reply to: Anonymous



This piece of info is not in the dxflist. This is the point I've been trying
to make.

Thanks for your time though,
Mark


"Jeff Mishler" wrote in message
news:3BF57E8EA640E1C21DE74721D4AD4F1D@in.WebX.maYIadrTaRb...
> Mark,
> Use this to list a door in the drawing, then find the dxf code for the
> "swing type". You could then use that code in your ssget.
> (entget (car (entsel)))
>
> HTH,
> Jeff
>
> "Mark Ingram" wrote in message
> news:940B00D75BFDDF4AD74BF5AA769403BB@in.WebX.maYIadrTaRb...
> > Would either of you have a moment to show me the equivalent of
> > (ssget "x" '((0 . "AEC_DOOR")(? . "Single Swing")))
> > in vlisp?
> >
> > I'm unable to get "Single Swing" from entget.
> >
> > Thank you,
> > Mark
> >
> >
> > "michael puckett" wrote in message
> > news:E345AF7AD7EFF607A27A3B92ECB1B1A1@in.WebX.maYIadrTaRb...
> > > 🙂
> > >
> > > ... I loosely recall the "guru of gurus" pointing
> > > out that specifying method / property names by symbols
> > > ( eg 'StyleName, rather than strings, eg "StyleName" )
> > > was more efficient: a hundred calls using a string
> > > yields a separate instance of the string for each call,
> > > whereas using a symbol results in the creation of
> > > precisely one object with references for each subsequent
> > > call. The bottom line being that the latter is better
> > > coding practice, even though the performance hit, or
> > > additional memory consumption might be negligible.
> > >
> > > Something like that.
> > >
> > > "R. Robert Bell" wrote in message
> > > news:2505058AA8C6FE4B802FE1551E26C332@in.WebX.maYIadrTaRb...
> > > 8^P
> > >
> > > Can tell you're a Cana-dude, throwing out a hockey reference. Around
> here
> > > I'd blow the whistle and proclaim a 5-yard penalty...
> > >
> > >
> > > --
> > > R. Robert Bell, MCSE
> > > www.AcadX.com
> > >
> > >
> > > "michael puckett" wrote in message
> > > news:C2CC1DCD127BAE52AE7266474DA3A9F9@in.WebX.maYIadrTaRb...
> > > | WHISTLE! 2 minutes, slow operation!
> > > |
> > > | (vl-catch-all-apply
> > > | 'vlax-get-property
> > > | (list object 'StyleName)
> > > | )
> > > |
> > > | 😉
> > > |
> > >
> > >
> > >
> >
> >
>
>
Message 22 of 33
Anonymous
in reply to: Anonymous

Sorry Mark, I'm completely unfamiliar with AEC dxf codes -- what kind of
property is "Single Swing" 😞

Like Jason said / eluded, you can pre process a selection set if you cannot
narrow the initial selection process with specific dxf group code values,
using ssdel to remove entities that do not additional criteria ...

"Mark Ingram" wrote in message
news:940B00D75BFDDF4AD74BF5AA769403BB@in.WebX.maYIadrTaRb...

Would either of you have a moment to show me the equivalent of
(ssget "x" '((0 . "AEC_DOOR")(? . "Single Swing")))
in vlisp?

I'm unable to get "Single Swing" from entget.

Thank you,
Mark
Message 23 of 33
Anonymous
in reply to: Anonymous

You are correct in your recollection. I simply missed that in the massaging
of the original statement.


--
R. Robert Bell, MCSE
www.AcadX.com


"michael puckett" wrote in message
news:E345AF7AD7EFF607A27A3B92ECB1B1A1@in.WebX.maYIadrTaRb...
| 🙂
|
| ... I loosely recall the "guru of gurus" pointing
| out that specifying method / property names by symbols
| ( eg 'StyleName, rather than strings, eg "StyleName" )
| was more efficient: a hundred calls using a string
| yields a separate instance of the string for each call,
| whereas using a symbol results in the creation of
| precisely one object with references for each subsequent
| call. The bottom line being that the latter is better
| coding practice, even though the performance hit, or
| additional memory consumption might be negligible.
|
| Something like that.
|
| "R. Robert Bell" wrote in message
| news:2505058AA8C6FE4B802FE1551E26C332@in.WebX.maYIadrTaRb...
| 8^P
|
| Can tell you're a Cana-dude, throwing out a hockey reference. Around here
| I'd blow the whistle and proclaim a 5-yard penalty...
|
|
| --
| R. Robert Bell, MCSE
| www.AcadX.com
|
|
| "michael puckett" wrote in message
| news:C2CC1DCD127BAE52AE7266474DA3A9F9@in.WebX.maYIadrTaRb...
| | WHISTLE! 2 minutes, slow operation!
| |
| | (vl-catch-all-apply
| | 'vlax-get-property
| | (list object 'StyleName)
| | )
| |
| | 😉
| |
|
|
|
Message 24 of 33
Anonymous
in reply to: Anonymous

Cannot be done without a dxf code. Sorry.

--
R. Robert Bell, MCSE
www.AcadX.com


"Mark Ingram" wrote in message
news:940B00D75BFDDF4AD74BF5AA769403BB@in.WebX.maYIadrTaRb...
| Would either of you have a moment to show me the equivalent of
| (ssget "x" '((0 . "AEC_DOOR")(? . "Single Swing")))
| in vlisp?
|
| I'm unable to get "Single Swing" from entget.
|
| Thank you,
| Mark
|
|
Message 25 of 33
Anonymous
in reply to: Anonymous

Typo alert:

... using ssdel to remove entities that do not >>>MEET<<< additional criteria
...

Also, why not use vlax-dump-object and entget on the same object(s) to
determine what properties are available and what could possibly be used to
narrow your selection?

Just a thought.

"michael puckett" wrote in message
news:0D837030E8D80AE8B7C1E9C5D13AAECA@in.WebX.maYIadrTaRb...
Sorry Mark, I'm completely unfamiliar with AEC dxf codes -- what kind of
property is "Single Swing" 😞

Like Jason said / eluded, you can pre process a selection set if you cannot
narrow the initial selection process with specific dxf group code values,
using ssdel to remove entities that do not additional criteria ...

"Mark Ingram" wrote in message
news:940B00D75BFDDF4AD74BF5AA769403BB@in.WebX.maYIadrTaRb...

Would either of you have a moment to show me the equivalent of
(ssget "x" '((0 . "AEC_DOOR")(? . "Single Swing")))
in vlisp?

I'm unable to get "Single Swing" from entget.

Thank you,
Mark
Message 26 of 33
Anonymous
in reply to: Anonymous

The style type would be "AEC_DOOR". (all door objects, or object type)
The style name would be "Single Swing" (name of door style)

The dxflist will tell me that the object selected is an "AEC_DOOR", but not
the name of the style of that particular door.

(vlax-dump-object (setq obj (vlax-ename->vla-object (car (entsel)))))
returns:

Select object: ; IAecDoor: Door entity - usually inserted into a drawing
anchored to a Wall
; Property values:
; Application (RO) = #
; Description = ""
; Document (RO) = #
; EndcapStyleName = "*By Wall Style*"
; Handle (RO) = "1E08"
; HasExtensionDictionary (RO) = 0
; HeadHeight = 84.0
; Height = 84.0
; Hyperlinks (RO) = #
; Layer = "A-Door"
; LeafWidth = 12.0
; Linetype = "ByLayer"
; LinetypeScale = 1.0
; Lineweight = -1
; Location = (114.469 0.0 0.0)
; MeasureTo = 0
; Normal = (0.0 0.0 1.0)
; ObjectID (RO) = 2130377920
; ObjectName (RO) = "AecDbDoor"
; OpenPercent = 50
; OwnerID (RO) = 2130361592
; PlotStyleName = "ByLayer"
; Rise = 24.0
; Rotation = 0.0
; SillHeight = 0.0
; StandardSizes = "3'-0\" X 7'-0\""
; Style = #
; StyleName = "Single Swing"
; SwingAngle = 90
; TrueColor = #
; VerticalAlignment = 1
; Visible = -1
; Width = 36.0
T

but this requires a pick. I would like to know how to get all of the
"AEC_DOOR" objects with the style name "Single Swing".
In other words the vlisp equivalent of (ssget "x" '((0 . "AEC_DOOR")(? .
"Single Swing")))

Thank you for your time Michael,
Mark



"michael puckett" wrote in message
news:0D837030E8D80AE8B7C1E9C5D13AAECA@in.WebX.maYIadrTaRb...
> Sorry Mark, I'm completely unfamiliar with AEC dxf codes -- what kind of
> property is "Single Swing" 😞
>
> Like Jason said / eluded, you can pre process a selection set if you
cannot
> narrow the initial selection process with specific dxf group code values,
> using ssdel to remove entities that do not additional criteria ...
>
> "Mark Ingram" wrote in message
> news:940B00D75BFDDF4AD74BF5AA769403BB@in.WebX.maYIadrTaRb...
>
> Would either of you have a moment to show me the equivalent of
> (ssget "x" '((0 . "AEC_DOOR")(? . "Single Swing")))
> in vlisp?
>
> I'm unable to get "Single Swing" from entget.
>
> Thank you,
> Mark
>
>
Message 27 of 33
Anonymous
in reply to: Anonymous

one way.....

(setq ss (ssget "x" '((0 . "AEC_DOOR"))))

(if ss
(progn
(setq i 0)
(setq ssNew (ssadd))
(repeat (sslength ss)
(setq obj (vlax-ename->vla-object (ssname ss i)))
(if (= "YourStyleName" (vla-get-stylename obj))
(ssadd (vlax-vla-object->ename obj) ssNew)
)
(setq i (1+ i))
)
)
)

ssNew now contains all AEC_DOORS that match your stylename

--

-Jason
Member of the Autodesk Discussion Forum Moderator Program


"Mark Ingram" wrote in message
news:E253798FCD606661A8E67FA173DFC698@in.WebX.maYIadrTaRb...
> I can't. The name isn't available. Even though I know I'm looking for
> "Single Swing", this is not available. That's the point I've been trying to
> make. If you entget a door, you can see "AEC_DOOR", but not "Single Swing",
> so you can't look for a match.
>
> Thanks,
> Mark
Message 28 of 33
Anonymous
in reply to: Anonymous

Ahhh, (self edit). Thanks Jason. Didn't think of that. Been trying to hard
at something so small. Time for a break.

Thanks again, 🙂
Mark



"Jason Piercey" wrote in message
news:6499BB03BE6F9B22878353B4C65914DB@in.WebX.maYIadrTaRb...
> one way.....
>
> (setq ss (ssget "x" '((0 . "AEC_DOOR"))))
>
> (if ss
> (progn
> (setq i 0)
> (setq ssNew (ssadd))
> (repeat (sslength ss)
> (setq obj (vlax-ename->vla-object (ssname ss i)))
> (if (= "YourStyleName" (vla-get-stylename obj))
> (ssadd (vlax-vla-object->ename obj) ssNew)
> )
> (setq i (1+ i))
> )
> )
> )
>
> ssNew now contains all AEC_DOORS that match your stylename
>
> --
>
> -Jason
> Member of the Autodesk Discussion Forum Moderator Program
>
>
> "Mark Ingram" wrote in message
> news:E253798FCD606661A8E67FA173DFC698@in.WebX.maYIadrTaRb...
> > I can't. The name isn't available. Even though I know I'm looking for
> > "Single Swing", this is not available. That's the point I've been trying
to
> > make. If you entget a door, you can see "AEC_DOOR", but not "Single
Swing",
> > so you can't look for a match.
> >
> > Thanks,
> > Mark
>
>
Message 29 of 33
Anonymous
in reply to: Anonymous

err... *too* hard.


"Mark Ingram" wrote in message
news:576F7EDC640EAE0537238388C8E3DC98@in.WebX.maYIadrTaRb...
> Been trying to hard
Message 30 of 33
Anonymous
in reply to: Anonymous

Perhaps ... < coded blind / untested >

(cond
( (setq ss (ssget "x" '((0 . "AEC_DOOR"))))
(repeat (setq i (sslength ss))
(if
(or
(vl-catch-all-error-p
(setq StyleName
(vl-catch-all-apply
'vlax-get-property
(list
(vlax-ename->vla-object
(setq ename
(ssname ss (setq i (1- i)))
)
)
'StyleName
)
)
)
)
(/= "Single Swing" StyleName)
)
(ssdel ename ss)
)
)
(repeat (setq i (sslength ss))
;
; process each kept entity (traps
; no entity(s) in selection set )
;
(setq ename (ssname ss (setq i (1- i))))
;
; do something with ename
;
)
)
)

...

"Mark Ingram" wrote in message
news:A834FA1046115004EAC35C61267C957F@in.WebX.maYIadrTaRb...
The style type would be "AEC_DOOR". (all door objects, or object type)
The style name would be "Single Swing" (name of door style)

The dxflist will tell me that the object selected is an "AEC_DOOR", but not
the name of the style of that particular door.

(vlax-dump-object (setq obj (vlax-ename->vla-object (car (entsel)))))
returns:

Select object: ; IAecDoor: Door entity - usually inserted into a drawing
anchored to a Wall
; Property values:
; Application (RO) = #
; Description = ""
; Document (RO) = #
; EndcapStyleName = "*By Wall Style*"
; Handle (RO) = "1E08"
; HasExtensionDictionary (RO) = 0
; HeadHeight = 84.0
; Height = 84.0
; Hyperlinks (RO) = #
; Layer = "A-Door"
; LeafWidth = 12.0
; Linetype = "ByLayer"
; LinetypeScale = 1.0
; Lineweight = -1
; Location = (114.469 0.0 0.0)
; MeasureTo = 0
; Normal = (0.0 0.0 1.0)
; ObjectID (RO) = 2130377920
; ObjectName (RO) = "AecDbDoor"
; OpenPercent = 50
; OwnerID (RO) = 2130361592
; PlotStyleName = "ByLayer"
; Rise = 24.0
; Rotation = 0.0
; SillHeight = 0.0
; StandardSizes = "3'-0\" X 7'-0\""
; Style = #
; StyleName = "Single Swing"
; SwingAngle = 90
; TrueColor = #
; VerticalAlignment = 1
; Visible = -1
; Width = 36.0
T

but this requires a pick. I would like to know how to get all of the
"AEC_DOOR" objects with the style name "Single Swing".
In other words the vlisp equivalent of (ssget "x" '((0 . "AEC_DOOR")(? .
"Single Swing")))

Thank you for your time Michael,
Mark



"michael puckett" wrote in message
news:0D837030E8D80AE8B7C1E9C5D13AAECA@in.WebX.maYIadrTaRb...
> Sorry Mark, I'm completely unfamiliar with AEC dxf codes -- what kind of
> property is "Single Swing" 😞
>
> Like Jason said / eluded, you can pre process a selection set if you
cannot
> narrow the initial selection process with specific dxf group code values,
> using ssdel to remove entities that do not additional criteria ...
>
> "Mark Ingram" wrote in message
> news:940B00D75BFDDF4AD74BF5AA769403BB@in.WebX.maYIadrTaRb...
>
> Would either of you have a moment to show me the equivalent of
> (ssget "x" '((0 . "AEC_DOOR")(? . "Single Swing")))
> in vlisp?
>
> I'm unable to get "Single Swing" from entget.
>
> Thank you,
> Mark
>
>
Message 31 of 33
Anonymous
in reply to: Anonymous

I'll try this too. Thank you Michael.
Mark


"michael puckett" wrote in message
news:4ECC8346F62DE0DA08F18DC5762C3F69@in.WebX.maYIadrTaRb...
> Perhaps ... < coded blind / untested >
>
> (cond
> ( (setq ss (ssget "x" '((0 . "AEC_DOOR"))))
> (repeat (setq i (sslength ss))
> (if
> (or
> (vl-catch-all-error-p
> (setq StyleName
> (vl-catch-all-apply
> 'vlax-get-property
> (list
> (vlax-ename->vla-object
> (setq ename
> (ssname ss (setq i (1- i)))
> )
> )
> 'StyleName
> )
> )
> )
> )
> (/= "Single Swing" StyleName)
> )
> (ssdel ename ss)
> )
> )
> (repeat (setq i (sslength ss))
> ;
> ; process each kept entity (traps
> ; no entity(s) in selection set )
> ;
> (setq ename (ssname ss (setq i (1- i))))
> ;
> ; do something with ename
> ;
> )
> )
> )
>
> ...
>
> "Mark Ingram" wrote in message
> news:A834FA1046115004EAC35C61267C957F@in.WebX.maYIadrTaRb...
> The style type would be "AEC_DOOR". (all door objects, or object type)
> The style name would be "Single Swing" (name of door style)
>
> The dxflist will tell me that the object selected is an "AEC_DOOR", but
not
> the name of the style of that particular door.
>
> (vlax-dump-object (setq obj (vlax-ename->vla-object (car (entsel)))))
> returns:
>
> Select object: ; IAecDoor: Door entity - usually inserted into a drawing
> anchored to a Wall
> ; Property values:
> ; Application (RO) = #
> ; Description = ""
> ; Document (RO) = #
> ; EndcapStyleName = "*By Wall Style*"
> ; Handle (RO) = "1E08"
> ; HasExtensionDictionary (RO) = 0
> ; HeadHeight = 84.0
> ; Height = 84.0
> ; Hyperlinks (RO) = #
> ; Layer = "A-Door"
> ; LeafWidth = 12.0
> ; Linetype = "ByLayer"
> ; LinetypeScale = 1.0
> ; Lineweight = -1
> ; Location = (114.469 0.0 0.0)
> ; MeasureTo = 0
> ; Normal = (0.0 0.0 1.0)
> ; ObjectID (RO) = 2130377920
> ; ObjectName (RO) = "AecDbDoor"
> ; OpenPercent = 50
> ; OwnerID (RO) = 2130361592
> ; PlotStyleName = "ByLayer"
> ; Rise = 24.0
> ; Rotation = 0.0
> ; SillHeight = 0.0
> ; StandardSizes = "3'-0\" X 7'-0\""
> ; Style = #
> ; StyleName = "Single Swing"
> ; SwingAngle = 90
> ; TrueColor = #
> ; VerticalAlignment = 1
> ; Visible = -1
> ; Width = 36.0
> T
>
> but this requires a pick. I would like to know how to get all of the
> "AEC_DOOR" objects with the style name "Single Swing".
> In other words the vlisp equivalent of (ssget "x" '((0 . "AEC_DOOR")(? .
> "Single Swing")))
>
> Thank you for your time Michael,
> Mark
>
>
>
> "michael puckett" wrote in message
> news:0D837030E8D80AE8B7C1E9C5D13AAECA@in.WebX.maYIadrTaRb...
> > Sorry Mark, I'm completely unfamiliar with AEC dxf codes -- what kind of
> > property is "Single Swing" 😞
> >
> > Like Jason said / eluded, you can pre process a selection set if you
> cannot
> > narrow the initial selection process with specific dxf group code
values,
> > using ssdel to remove entities that do not additional criteria ...
> >
> > "Mark Ingram" wrote in message
> > news:940B00D75BFDDF4AD74BF5AA769403BB@in.WebX.maYIadrTaRb...
> >
> > Would either of you have a moment to show me the equivalent of
> > (ssget "x" '((0 . "AEC_DOOR")(? . "Single Swing")))
> > in vlisp?
> >
> > I'm unable to get "Single Swing" from entget.
> >
> > Thank you,
> > Mark
> >
> >
>
>
>
Message 32 of 33
PeterSCiganek
in reply to: Anonymous

Mark - maybe these functions will be useful:

(defun adt:ssget_bystyle (pat / ret)
(setq pat (strcase pat))
(if (ssget '((0 . "AEC*")))
(vlax-map-Collection (vla-get-ActiveSelectionSet (fx:doc))
'(lambda (e / nam)
(if (and (setq nam (f:vlget (list e 'StyleName) nil))
(wcmatch (strcase nam) pat)
)
(setq ret (append ret (list e)))
);if
)
);map
);if
ret
)

;;f:vlerr simplified error catching routine for vl-catch*
;;f:vlerr usage (setq en (f:vlerr 'vla-get-Area (list en) nil))
;;f:vlerr tag = true for debugging: princes error message

(defun f:vlerr (fun lst tag / ret *error*)

(if (vl-catch-all-error-p (setq ret (vl-catch-all-apply fun lst)))
(if tag
(progn (f:prm (list "\n" (vl-catch-all-error-message ret) "\n" fun lst)) nil)
nil
)
(if (not ret) (setq ret T) ret)
)
(if (= (type ret) 'VL-CATCH-ALL-APPLY-ERROR) (setq ret nil))

ret)

;;f:vlget as f:vlerr with vlax-get-property
(defun f:vlget (lst echo) (f:vlerr 'vlax-get-property lst echo))
;;f:vlput as f:vlerr with vlax-put-property
(defun f:vlput (lst echo) (f:vlerr 'vlax-put-property lst echo))
;;f:vldo as f:vlerr with vlax-invoke-method
(defun f:vldo (lst echo) (f:vlerr 'vlax-invoke-method lst echo))

(fx:doc) is the active document

Peter
Message 33 of 33
Anonymous
in reply to: Anonymous

You're welcome Mark.

"Mark Ingram" wrote in message
news:798C6AD1854E70980B43012E9507E1A3@in.WebX.maYIadrTaRb...

I'll try this too. Thank you Michael.
Mark

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

Post to forums  

Autodesk Design & Make Report

”Boost